Example #1
0
        internal override void RenderLabelView(WebGridHtmlWriter writer, RowCell cell)
        {
            string image = FileSource(false, cell);

            if (HyperLinkColumn && Grid.DisplayView == DisplayView.Grid)
            {
                string a = Grid.EnableCallBack ? Asynchronous.GetCallbackEventReference(Grid,
                                                                                        string.Format("RecordClick!{0}!{1}", ColumnId,
                                                                                                      cell.Row.PrimaryKeyValues),
                                                                                        false, string.Empty, string.Empty) : Grid.Page.ClientScript.GetPostBackEventReference(Grid,
                                                                                                                                                                              string.Format("RecordClick!{0}!{1}",
                                                                                                                                                                                            ColumnId,
                                                                                                                                                                                            cell.Row.
                                                                                                                                                                                            PrimaryKeyValues));

                string b = (String.IsNullOrEmpty(ConfirmMessage))
                               ? string.Empty
                               : String.Format("if(wgconfirm('{0}',this,'{1}')) ", ConfirmMessage.Replace("'", "\\'"), Grid.DialogTitle.Replace("'", "\\'"));

                image =
                    string.Format(
                        "<a class=\"wglinkfield\" href=\"#\" onclick=\"{0}{1}\">{2}</a>", b, a, image);
            }

            LabelHtml(image, writer, cell);
        }
Example #2
0
        internal override void RenderEditView(HtmlTextWriter writer, RowCell cell)
        {
            if (Table.m_GotData == false) // Data need to be recovered if CacheDatasourceStructure is active.
            {
                Table.GetData(true);
            }

            if (Identity || AllowEdit == false || (Grid.DisplayView == DisplayView.Grid && AllowEditInGrid == false))
            {
                RenderLabelView(writer, cell);
                return;
            }

            if (string.IsNullOrEmpty(ValueColumn))
            {
                throw new GridException(
                          String.Format(Table.m_Grid.GetSystemMessage("SystemMessage_ForeignkeyNoValueColumn"), Title));
            }

            StringBuilder s = new StringBuilder(string.Empty);

            switch (ForeignkeyType)
            {
            case ForeignkeyType.Select:
            case ForeignkeyType.SelectMenu:
            {
                StringBuilder eventScript = new StringBuilder(string.Empty);
                StringBuilder javascript  = new StringBuilder(string.Empty);
                if (AutoPostback || string.IsNullOrEmpty(ConfirmMessage) == false)
                {
                    eventScript = new StringBuilder(" onchange=\"");
                    if (string.IsNullOrEmpty(ConfirmMessage) == false)
                    {
                        eventScript.AppendFormat(" if(wgconfirm('{0}',this,'{1}')) ",
                                                 ConfirmMessage.Replace("'", "\\'"),
                                                 Grid.DialogTitle.Replace("'", "\\'"));
                    }
                    string link = Grid.EnableCallBack && !ForcePostBack
                                              ? Asynchronous.GetCallbackEventReference(Grid,
                                                                                       string.Format(
                                                                                           "ElementPostBack!{0}!{1}",
                                                                                           ColumnId,
                                                                                           cell.Row.PrimaryKeyValues),
                                                                                       false,
                                                                                       string.Empty,
                                                                                       string.Empty)
                                              : Grid.Page.ClientScript.GetPostBackEventReference(Grid,
                                                                                                 string.Format(
                                                                                                     "ElementPostBack!{0}!{1}",
                                                                                                     ColumnId,
                                                                                                     cell.Row.
                                                                                                     PrimaryKeyValues));

                    eventScript.AppendFormat("{0}\"", link);
                }

                StringBuilder onblur = new StringBuilder(" onblur=\"");

                if (Grid.ColumnChangedColour != Color.Empty)
                {
                    onblur.AppendFormat("isChanged(this,'{0}');", Grid.ColorToHtml(Grid.ColumnChangedColour));
                }
                onblur.Append("\"");
                javascript.Append(onblur);
                s.AppendFormat("<select {0} class=\"wgeditfield wgselectbox {4}\" id=\"{1}\" name=\"{1}\" {2} {3}>",
                               javascript, cell.CellClientId, eventScript, Attributes, CssClass);
                if (m_Foreignkeytype == ForeignkeyType.SelectMenu && (Grid.Scripts == null || !Grid.Scripts.DisableSelectMenu))
                {
                    if (SelectMenuWidth > 0)
                    {
                        Grid.AddClientScript(writer,
                                             string.Format(
                                                 "$(document).ready(function() {{$('#{0}').selectmenu({{maxHeight: {2},style:'dropdown',width: {1}}});}});",
                                                 cell.CellClientId, SelectMenuWidth, SelectMenuMaxHeight));
                    }
                    else
                    {
                        Grid.AddClientScript(writer,
                                             string.Format(
                                                 "$(document).ready(function() {{$('#{0}').selectmenu({{maxHeight: {1},style:'dropdown'}});}});",
                                                 cell.CellClientId, SelectMenuMaxHeight));
                    }
                }

                if (Table.Rows.Count == 0 && NullText == null)
                {
                    NullText = "No data available.";
                }

                if (NullText != null)
                {
                    s.AppendFormat("<option value=\"{1}\">{0}</option>", NullText, string.Empty);
                }

                //CreateRows(Grid,tree,null,0);

                s.Append(CreateSelectRows(TreeParentId != null, null, 0, cell));
                s.Append("</select>");
            }
            break;

            case ForeignkeyType.Radiobuttons:
                m_IsFormElement = false;
                m_Rowcounter    = RecordsPerRow;
                s.AppendFormat("<table class=\"wgradiobuttons {1}\"><tr><td>{0}</td></tr></table>",
                               CreateRadioButtons((TreeParentId != null), null, 0, cell), CssClass);
                break;
            }

            if (string.IsNullOrEmpty(ToolTipInput) == false)
            {
                s = new StringBuilder(Tooltip.Add(s.ToString(), ToolTipInput));
            }

            EditHtml(s.ToString(), writer, cell);
        }
Example #3
0
        // 2005.01.09 - jorn -  String.Compare, string.Length
        // 2005.01.05 - Jorn -  Added check to see if there actually is a checkbox on "previous page".
        //                        Need to add a hidden field since checkbox "returns null" both for unchecked and non-existing
        internal void RenderDetail(bool enabled, WebGridHtmlWriter writer, RowCell cell)
        {
            if (AllowEdit == false || (Grid.DisplayView == DisplayView.Grid && AllowEditInGrid == false))
            {
                enabled = false;
            }

            string       uniqueId       = cell.CellClientId;
            string       strValue       = DisplayText(cell);
            const string checkedValue   = TrueValue;
            const string uncheckedValue = FalseValue;

            StringBuilder sb;

            if (String.Compare(strValue, checkedValue, true) == 0 && CheckedAlias != null && enabled == false)
            {
                sb = new StringBuilder(CheckedAlias);
            }
            else if (String.Compare(strValue, uncheckedValue, true) == 0 && UncheckedAlias != null &&
                     enabled == false)
            {
                sb = new StringBuilder(UncheckedAlias);
            }
            else
            {
                string bitchecked = string.Empty;
                string bitEnabled = string.Empty;
                if (String.Compare(strValue, checkedValue, true) == 0)
                {
                    bitchecked = " checked=\"checked\"";
                }
                if (enabled == false)
                {
                    bitEnabled = " disabled=\"disabled\"";
                }

                StringBuilder javascript = new StringBuilder(string.Empty);
                StringBuilder onblur     = new StringBuilder(" onblur=\"");
                if (Grid.InputHighLight != Color.Empty)
                {
                    javascript.AppendFormat(
                        " onfocus=\"this.accessKey = this.style.backgroundColor;this.style.backgroundColor='{0}';\"",
                        Grid.ColorToHtml(Grid.InputHighLight));
                    onblur.Append("this.style.backgroundColor=this.accessKey;");
                }
                if (Grid.ColumnChangedColour != Color.Empty)
                {
                    onblur.AppendFormat("isChanged(this,'{0}');", Grid.ColorToHtml(Grid.ColumnChangedColour));
                }
                onblur.Append("\"");

                if (AutoPostback || string.IsNullOrEmpty(ConfirmMessage) == false)
                {
                    StringBuilder eventScript = new StringBuilder(" onclick=\"");
                    if (string.IsNullOrEmpty(ConfirmMessage) == false)
                    {
                        eventScript.AppendFormat(" if(wgconfirm('{0}',this,'{1}')) ", ConfirmMessage.Replace("'", "\\'"), Grid.DialogTitle.Replace("'", "\\'"));
                    }
                    string link = Grid.EnableCallBack && !ForcePostBack?Asynchronous.GetCallbackEventReference(Grid,
                                                                                                               string.Format("ElementPostBack!{0}!{1}",
                                                                                                                             ColumnId, cell.Row.PrimaryKeyValues), false,
                                                                                                               string.Empty, string.Empty) : Grid.Page.ClientScript.GetPostBackEventReference(Grid,
                                                                                                                                                                                              string.Format(
                                                                                                                                                                                                  "ElementPostBack!{0}!{1}", ColumnId, cell.Row.PrimaryKeyValues));

                    eventScript.AppendFormat("{0}\"", link);

                    javascript.Append(eventScript);
                }
                javascript.Append(onblur);
                sb =
                    new StringBuilder(
                        string.Format(
                            "<input {0} type=\"checkbox\" {1} {2} {4}  id=\"cb_{3}\" name=\"{3}\" value=\"1\"/>",
                            javascript, bitchecked, bitEnabled, uniqueId, Attributes));
                if (string.IsNullOrEmpty(m_Displaylabel) == false)
                {
                    sb.AppendFormat(
                        "<label class=\"wglabel\" id=\"label_{0}\" for=\"cb_{0}\">{1}</label>", uniqueId, m_Displaylabel);
                }

                if (enabled)
                {
                    writer.Write("<input type=\"hidden\" id=\"{0}_cb\" name=\"{0}_cb\" value=\"{1}\" />",
                                 uniqueId, checkedValue);
                }
            }

            if (string.IsNullOrEmpty(ToolTipInput) == false)
            {
                sb = new StringBuilder(Tooltip.Add(sb.ToString(), ToolTipInput));
            }

            EditHtml(sb.ToString(), writer, cell);
        }
Example #4
0
        // 2005.01.19 - jorn, added this recursive function.
        private void RenderDetailTree(StringBuilder sb, string parentID, int level, RowCell cell)
        {
            if (parentID == null)
            {
                parentID = string.Empty;
            }
            List <string> selectedItems = new List <string>();

            if (cell.Value != null && Grid.Page != null && Grid.Page.IsPostBack)
            {
                selectedItems.InsertRange(0, cell.Value.ToString().Split(','));
            }

            for (int i = 0; i < Items.Count; i++)
            {
                if ((Items[i].ParentId ?? string.Empty) != parentID)
                {
                    continue;
                }
                if (Grid.Page != null && Grid.Page.IsPostBack && selectedItems.Count > 0)
                {
                    Items[i].Checked = selectedItems.Contains(Items[i].Value);
                }

                StringBuilder indentText = new StringBuilder(string.Empty);
                if (level > 0)
                {
                    for (int j = 0; j < level; j++)
                    {
                        indentText.Append(TreeIndentText);
                    }
                }

                StringBuilder selected = new StringBuilder(string.Empty);

                if (Items[i].Checked)
                {
                    selected.Append(ManyToManyType == ManyToManyType.Multiselect
                                        ? " selected=\"selected\" "
                                        : " checked=\"checked\" ");
                }
                if (AllowEdit == false)
                {
                    selected.Append(" disabled=\"disabled\" ");
                }

                if (ManyToManyType == ManyToManyType.Multiselect)
                {
                    sb.AppendFormat("<option {0} value=\"{1}\">{2}{3}</option>", selected, Items[i].Value, indentText,
                                    Items[i].DisplayText);
                }
                else
                {
                    if (i != 0)
                    {
                        if (m_Rowcounter == 0)
                        {
                            sb.Append("</tr><tr><td>");
                            m_Rowcounter = RecordsPerRow;
                        }
                        else
                        {
                            sb.Append("<td>");
                        }
                    }
                    m_Rowcounter--;
                    sb.Append(indentText);

                    StringBuilder javascript = new StringBuilder(string.Empty);
                    StringBuilder onblur     = new StringBuilder(" onblur=\"");
                    if (Grid.InputHighLight != Color.Empty)
                    {
                        javascript.AppendFormat(
                            " onfocus=\"this.accessKey = this.style.backgroundColor;this.style.backgroundColor='{0}';\"",
                            Grid.ColorToHtml(Grid.InputHighLight));
                        onblur.Append("this.style.backgroundColor=this.accessKey;");
                    }
                    if (Grid.ColumnChangedColour != Color.Empty)
                    {
                        onblur.AppendFormat("isChanged(this,'{0}');", Grid.ColorToHtml(Grid.ColumnChangedColour));
                    }
                    onblur.Append("\"");
                    javascript.Append(onblur);

                    if ((AutoPostback || !string.IsNullOrEmpty(ConfirmMessage)) && Grid.Page != null)
                    {
                        StringBuilder eventScript = new StringBuilder(" onclick=\"");
                        if (!string.IsNullOrEmpty(ConfirmMessage))
                        {
                            eventScript.AppendFormat(" if(wgconfirm('{0}',this),'{1}') ", ConfirmMessage.Replace("'", "\\'"), Grid.DialogTitle.Replace("'", "\\'"));
                        }
                        string link = Grid.EnableCallBack && !ForcePostBack
                                          ? Asynchronous.GetCallbackEventReference(Grid,
                                                                                   string.Format(
                                                                                       "ElementPostBack!{0}!{1}",
                                                                                       ColumnId,
                                                                                       cell.Row.PrimaryKeyValues),
                                                                                   false,
                                                                                   string.Empty, string.Empty)
                                          : Grid.Page.ClientScript.GetPostBackEventReference(Grid,
                                                                                             string.Format(
                                                                                                 "ElementPostBack!{0}!{1}",
                                                                                                 ColumnId,
                                                                                                 cell.Row.
                                                                                                 PrimaryKeyValues));

                        eventScript.AppendFormat("{0}\"{1}", link, eventScript);
                        javascript.Append(eventScript);
                    }

                    if (!string.IsNullOrEmpty(CheckedAlias) && Items[i].Checked)
                    {
                        sb.Append(CheckedAlias);
                        sb.Append(Items[i].DisplayText);
                    }
                    else if (!string.IsNullOrEmpty(UncheckedAlias) && !Items[i].Checked)
                    {
                        sb.Append(UncheckedAlias);
                        sb.Append(Items[i].DisplayText);
                    }
                    else
                    {
                        sb.AppendFormat(
                            "<input {0} type=\"checkbox\" id=\"cb_{1}_{2}\" name=\"{1}\" value=\"{2}\" {3} />",
                            javascript, cell.CellClientId,
                            Items[i].Value, selected);
                        sb.AppendFormat(
                            "<label class=\"wglabel\"  id=\"label_{0}_{1}\" for=\"cb_{0}_{1}\">", cell.CellClientId, Items[i].Value);

                        sb.AppendFormat("{0}</label>", Items[i].DisplayText);
                    }
                    sb.Append("</td>");
                }

                RenderDetailTree(sb, Items[i].Value, level + 1, cell);
            }
        }
Example #5
0
        internal override void RenderLabelView(WebGridHtmlWriter writer, RowCell cell)
        {
            string image = FileSource(true, cell);

            if (!string.IsNullOrEmpty(PopupImageColumn))
            {
                if (!cell.Row.Columns.Contains(PopupImageColumn))
                {
                    throw new ApplicationException(
                              string.Format(@"""PopupImageColumn"" property value for column '{0}' is not valid.", Title));
                }
                string rel = "";
                if (m_PopupImageDisplayType == ImageDisplayType.Navigation || m_PopupImageDisplayType == ImageDisplayType.NavigationSlideShow)
                {
                    rel = string.Format("rel=\"{0}_{1}\"", Grid.ClientID, ColumnId);
                }
                image =
                    string.Format(@"<a href=""{1}"" title=""{3}"" {4} class=""wgimage_{5}""><img class=""wgimage"" src=""{0}"" alt=""{2}""/></a>",
                                  image, ((Image)cell.Row.Columns[PopupImageColumn]).GetUrl(cell.Row[PopupImageColumn]), Title, PopupImageCaption, rel, ColumnId);
                switch (PopupImageDisplayType)
                {
                case ImageDisplayType.Navigation:
                    Grid.AddClientScript(writer, string.Format("$(\"a[rel='{0}_{1}']\").colorbox({{slideshow:false}});", Grid.ClientID, ColumnId));
                    break;

                case ImageDisplayType.NavigationSlideShow:
                    Grid.AddClientScript(writer, string.Format("$(\"a[rel='{0}_{1}']\").colorbox({{slideshow:true}});", Grid.ClientID, ColumnId));
                    break;

                case ImageDisplayType.Single:
                    Grid.AddClientScript(writer, string.Format("$(document).ready(function() {{$(\".wgimage_{0}\").colorbox();}});", ColumnId));
                    break;
                }
            }
            else
            {
                image = string.Format(@"<img class=""wgimage"" src=""{0}"" alt=""{1}""/>", image, Title);
            }

            if (HyperLinkColumn && Grid.DisplayView == DisplayView.Grid)
            {
                string a = Grid.EnableCallBack ? Asynchronous.GetCallbackEventReference(Grid,
                                                                                        string.Format("RecordClick!{0}!{1}", ColumnId,
                                                                                                      cell.Row.PrimaryKeyValues),
                                                                                        false, string.Empty, string.Empty) : Grid.Page.ClientScript.GetPostBackEventReference(Grid,
                                                                                                                                                                              string.Format("RecordClick!{0}!{1}",
                                                                                                                                                                                            ColumnId,
                                                                                                                                                                                            cell.Row.
                                                                                                                                                                                            PrimaryKeyValues));

                string b = (String.IsNullOrEmpty(ConfirmMessage))
                               ? string.Empty
                               : String.Format("if(wgconfirm('{0}',this,'{1}')) ", ConfirmMessage.Replace("'", "\\'"), Grid.DialogTitle.Replace("'", "\\'"));

                image =
                    string.Format(
                        "<a class=\"wglinkfield\" href=\"#\" onclick=\"{0}{1}\">{2}</a>", b, a, image);
            }

            LabelHtml(image, writer, cell);
        }