Esempio n. 1
0
        // 2005.01.09 - jorn, string optimize, String.Compare
        internal override void RenderEditView(WebGridHtmlWriter writer, RowCell cell)
        {
            if (AllowEdit == false || (Grid.DisplayView == DisplayView.Grid && AllowEditInGrid == false))
            {
                RenderLabelView(writer, cell);
                return;
            }

            base.RenderEditView(writer, cell);

            if (DisplayCalendar && Grid.GotHttpContext)
            {
                Grid.AddClientScript(writer, string.Format(calendarsetup, cell.CellClientId,
                                                           CalendarFormat, AddCalendarClientAttributes,
                                                           Grid.Page.ClientScript.GetWebResourceUrl(Grid.GetType(),
                                                                                                    "WebGrid.Resources.images.calendar.gif")));
            }
        }
Esempio n. 2
0
        internal override void RenderLabelView(HtmlTextWriter writer, RowCell cell)
        {
            if (!Grid.EnableCallBack)
            {
                throw new GridException("WebGrid must have callback enabled to use tooltip columns, you can enable this by setting 'Grid.EnableCallBack=true'");
            }
            string clientId    = ToolTipClientId ?? string.Format("{0}{1}TP{2}", Grid.ID, ColumnId, cell.Row.RowIndex);
            string closebutton = null;

            if (CloseButtonText != null)
            {
                closebutton = string.Format(",button: '{0}'", CloseButtonText);
            }

            Grid.AddClientScript(writer, string.Format(template, clientId,
                                                       Grid.ClientID, ShowMethod, HideMethod, ToolTipWidth,
                                                       ToolTipHeight,
                                                       string.Format("{0}!{1}", ColumnId, cell.Row.PrimaryKeyValues)
                                                       , ToolTipStyle, SingleToolTip.ToString().ToLower(), ContentText,
                                                       Title, closebutton));

            LabelHtml(string.Format("<div class=\"wgtoolelement\" id=\"{0}{1}TP{2}\">{3}</div>", Grid.ID, ColumnId,
                                    cell.Row.RowIndex, Text), writer, cell);
        }
Esempio n. 3
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);
        }
Esempio n. 4
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);
        }