コード例 #1
0
        internal static void CreateTitle(Grid grid, DisplayView mode, WebGridHtmlWriter writer, int[] sortedColumnID,
                                         int editMaxCells, string tagstyle)
        {
            string strclass = "wgtitlegrid";

            if (mode == DisplayView.Detail)
            {
                strclass = "wgtitledetail";
            }

            bool isHeader = GetIsHeader(grid);

            if (!isHeader)
            {
                return;
            }
            if (grid.IsUsingJQueryUICSSFramework && grid.DisplayView == DisplayView.Detail)
            {
                writer.Write("<tr class=\"ui-widget-header wgrow\">");
            }
            else
            {
                writer.Write("<tr class=\"wgrow\">");
            }

            ColumnHeader header = new ColumnHeader
            {
                m_ColumnSpan = (mode == DisplayView.Grid ? sortedColumnID.Length : editMaxCells),
                m_Class      = string.Format("{0} wgheadercell", strclass)
            };

            header.RenderBeginTag(writer, null, null, string.Format("<{0}", tagstyle));
            writer.Write(grid.Title);
            header.RenderEndTag(writer, string.Format("</{0}>", tagstyle));
            writer.Write("</tr>");
        }
コード例 #2
0
ファイル: RenderingMethods.cs プロジェクト: webgrid/WebGrid
        internal static void CreateFilterByColumns(Grid grid, WebGridHtmlWriter writer, int[] sortedColumnID)
        {
            grid.m_RowsAdded++;
            writer.Write(
                grid.IsUsingJQueryUICSSFramework
                    ? "<tr class=\"ui-widget wgrow\" id=\"{0}r{1}\">"
                    : "<tr class=\"wgrow\" id=\"{0}r{1}\">", grid.ID, grid.m_RowsAdded);
            for (int ii = 0; ii < sortedColumnID.Length; ii++)
            {
                Column column = grid.MasterTable.Columns[sortedColumnID[ii]];
                if (column.FilterByColumnCollection.Count == 0)
                {
                    string columnstyle = string.Empty;
                    string columnId = string.Format(" id=\"{0}{1}r{2}\"", grid.ID, column.ColumnId, grid.m_RowsAdded);
                    if (grid.MasterTable.Columns[column.ColumnId].WidthColumnHeaderTitle != Unit.Empty)
                        columnstyle =
                            string.Format("style=\"width: {0};\"",
                                          grid.MasterTable.Columns[column.ColumnId].WidthColumnHeaderTitle);
                    writer.Write("<th {0} {1}>&nbsp;</th>", columnstyle,columnId);
                    continue;
                }

                ColumnHeader addcolumn = new ColumnHeader
                                   {
                                       m_Class = string.Format("{0} wggridcell", column.CssClassTitle),
                                       m_Align = column.GridAlign,
                                       m_VAlign = VerticalPosition.bottom,
                                       m_ColumnWidth =
                                           grid.MasterTable.Columns[column.ColumnId].WidthColumnHeaderTitle,
                                       m_GridRowCount = grid.m_RowsAdded,

                                       m_GridId = grid.ID
                                   };

                addcolumn.RenderBeginTag(writer,column,null,"<th");

                string selectedValue = null;
                if (Grid.GotHttpContext &&
                    HttpContext.Current.Request.Form[string.Format("ddl{0}", column.ClientHeaderId)] != null)
                {
                    selectedValue =
                        HttpUtility.HtmlEncode(
                            HttpContext.Current.Request.Form[string.Format("ddl{0}", column.ClientHeaderId)]);
                    grid.State(string.Format("ddl{0}", column.ClientHeaderId), selectedValue);
                }
                else if (grid.GetState(string.Format("ddl{0}", column.ClientHeaderId)) != null)
                    selectedValue = grid.GetState(string.Format("ddl{0}", column.ClientHeaderId)) as string;
                bool isdate = false;
                if (grid.MasterTable.Columns[column.ColumnId].ColumnType == ColumnType.DateTime)
                    isdate = true;

                string eventScript = string.Empty;
                if (grid.Page != null)
                {
                    string link = grid.EnableCallBack && !column.ForcePostBack ? Asynchronous.GetCallbackEventReference(grid,
                                                                                               string.Format("ElementPostBack!ddl{0}",
                                                                                                             column.ColumnId), false,
                                                                                               string.Empty, string.Empty) : grid.Page.ClientScript.GetPostBackEventReference(grid,
                                                                                                                                                                              string.Format("ElementPostBack!ddl{0}",
                                                                                                                                                                                            column.ColumnId));
                    eventScript = string.Format(" onchange=\"{0}\" ", link);
                }
                string style = grid.MasterTable.Columns[column.ColumnId].WidthColumnHeaderTitle != Unit.Empty ? "class=\"wgeditfield wgselectbox \"" : " class=\"wgeditfield wgselectbox \" ";

                if (!isdate)
                {
                    StringBuilder dropdownbox = new StringBuilder("<select ");
                    dropdownbox.AppendFormat("{0} name=\"ddl{1}\" id=\"ddl{1}\" {2}><option value=\"\" selected=\"selected\">{3}</option>", style, column.ClientHeaderId, eventScript, column.Grid.GetSystemMessage("EmptySearchFilter"));

                    if (grid.Scripts == null || !grid.Scripts.DisableSelectMenu)
                        Grid.AddClientScript(writer, string.Format("$(document).ready(function() {{$('#ddl{0}').selectmenu({{maxHeight: {2},style:'dropdown',width: {1}}});}});", column.ClientHeaderId, column.WidthColumnHeaderTitle.Value, 400));

                    int i = 0;
                    while (i < column.FilterByColumnCollection.Count)
                    {
                        string _value = HttpUtility.HtmlEncode(column.FilterByColumnCollection[i]);
                        string _title = HttpUtility.HtmlEncode(column.FilterByColumnCollection.GetKey(i));
                        if (selectedValue != null && selectedValue == _value)
                            dropdownbox.AppendFormat("<option selected=\"selected\" value=\"{0}\">{1}</option>",
                                                     HttpUtility.HtmlEncode(column.FilterByColumnCollection[i]), _title);
                        else
                            dropdownbox.AppendFormat("<option value=\"{0}\">{1}</option>",
                                                     HttpUtility.HtmlEncode(column.FilterByColumnCollection[i]), _title);
                        i++;
                    }

                    writer.Write(dropdownbox);
                    writer.Write("</select> ");
                }
                else
                {
                    if (grid.DatabaseConnectionType != DataBaseConnectionType.SqlConnection)
                        throw new GridException(
                            string.Format("'FilterByColumn' property for 'DateTime' ({0}) columns are only supported by 'SqlConnection' connection strings.", column.ColumnId));
                    writer.Write("<span style=\"white-space: nowrap;vertical-align:middle;\">");

                    string filter = ((WebGrid.DateTime)grid.MasterTable.Columns[column.ColumnId]).SearchFilter;

                    if (string.IsNullOrEmpty(filter))
                    {
                        StringBuilder s = new StringBuilder(string.Empty);
                        s.AppendFormat(
                            "<a class=\"wglinkfield\" href=\"?DateFilter={0}\">{1}</a>",
                             grid.MasterTable.Columns[column.ColumnId].ColumnId,
                            column.Grid.GetSystemMessage("DateTimeSearch"));
                        writer.Write(s);
                    }
                    else
                    {
                        StringBuilder s = new StringBuilder(string.Empty);
                        s.AppendFormat(
                            "<a class=\"wglinkfield\" href=\"#\"   onclick=\"javascript:WGdisableDateTimeSearch('{0}');\";return false;\">{1}</a>",
                            column.ColumnId,column.Grid.GetSystemMessage("DateTimeSearchReset"));
                        writer.Write(s);
                    }
                    // From date
                    writer.Write("</span>");
                }
                addcolumn.RenderEndTag(writer,"</th>");
            }

            writer.Write("</tr>");
        }
コード例 #3
0
ファイル: RenderingMethods.cs プロジェクト: webgrid/WebGrid
        internal static void CreateTitle(Grid grid, DisplayView mode, WebGridHtmlWriter writer, int[] sortedColumnID,
            int editMaxCells, string tagstyle)
        {
            string strclass = "wgtitlegrid";
            if (mode == DisplayView.Detail)
                strclass = "wgtitledetail";

            bool isHeader = GetIsHeader(grid);

            if (!isHeader) return;
            if (grid.IsUsingJQueryUICSSFramework && grid.DisplayView == DisplayView.Detail)
                writer.Write("<tr class=\"ui-widget-header wgrow\">");
            else
                writer.Write("<tr class=\"wgrow\">");

            ColumnHeader header = new ColumnHeader
                                      {
                                          m_ColumnSpan =(mode == DisplayView.Grid ? sortedColumnID.Length : editMaxCells),
                                          m_Class = string.Format("{0} wgheadercell", strclass)
                                      };

            header.RenderBeginTag(writer, null, null, string.Format("<{0}", tagstyle));
            writer.Write(grid.Title);
            header.RenderEndTag(writer, string.Format("</{0}>", tagstyle));
            writer.Write("</tr>");
        }
コード例 #4
0
ファイル: Rendering.cs プロジェクト: webgrid/WebGrid
        internal static void RenderDetail(ref Grid grid, ref WebGridHtmlWriter writer)
        {
            string width = grid.Width.IsEmpty == false ? grid.Width.ToString() : "100%";

            /* cellpadding and cellspacing are fixed because CSS does not support similar behavior*/
            if (grid.IsUsingJQueryUICSSFramework)
                writer.Write( //ui-helper-reset
                    "<table width=\"{0}\" class=\"ui-widget-content  wgmaindetail\" cellspacing=\"0\" cellpadding=\"0\">", width);
            else
                writer.Write("<table width=\"{0}\" class=\"wgmaindetail\" cellspacing=\"0\" cellpadding=\"0\">", width);

            int[] sortedColumns = grid.VisibleSortedColumns;

            int columnWidth = -1;
            int allRowsColumns = 0;
            int ant = 0;

            bool firstvisiblecolumn = true;

            bool editablecolumns = grid.m_Forceeditablecolumns;

            for (int i = 0; i < sortedColumns.Length; i++)
            {
                ant += 2;
                // if( Grid.BasicDetailLayout )
                //	 ant--;
                if (grid.DisplayRequiredColumn)
                    ant++;

                if (ant > columnWidth)
                    columnWidth = ant;

                Column c = grid.MasterTable.Columns[sortedColumns[i]];
                if (c.UseAllRows)
                    allRowsColumns++;
                if (c.IsVisible == false)
                    continue;
                if (editablecolumns == false && c.AllowEdit)
                    editablecolumns = true;
                if (firstvisiblecolumn)
                {
                    firstvisiblecolumn = false;
                    continue;
                }
                if (c.NewRowInDetail)
                    ant = 0;
            }
            // Create head
            CreateTitle(grid, DisplayView.Detail, writer, sortedColumns, columnWidth,"td");

            if ((grid.CollapseIfSlaveGrid && grid.ActiveMenuSlaveGrid != null) || grid.CollapsedGrid)
            {
                writer.Write("</table>");
                return;
            }
            // Create toolbar
            if (string.IsNullOrEmpty(grid.GetToolbarHtml(ToolbarType.ToolbarDetailTop)) == false)
            {
                if( grid.IsUsingJQueryUICSSFramework)
                writer.Write(
                    "<tr class=\"ui-widget-header wgrow\"><td class=\"wgtoolbardetail\" colspan=\"{0}\">",
                    columnWidth);
                else
                    writer.Write(
                          "<tr class=\"wgrow\"><td class=\"wgtoolbardetail\" colspan=\"{0}\">",
                          columnWidth);
                CreateDetailToolbar(grid.GetToolbarHtml(ToolbarType.ToolbarDetailTop), writer, grid, editablecolumns);
                writer.Write("</td></tr>");
            }
            int antcols = 0;
            if (allRowsColumns > 0)
                writer.Write(
                    "<tr><td colspan=\"{0}\"><table class=\"wgrowspan\"><tr valign=\"top\"><td><table class=\"wgrowspan\">",
                    columnWidth);
            grid.MasterTable.Rows[0].RowIndex = -1;
            for (int i = 0; i < sortedColumns.Length; i++)
            {
                Column column = grid.MasterTable.Rows[0] != null ? grid.MasterTable.Columns[sortedColumns[i]] : grid.MasterTable.Columns[sortedColumns[i]];
                if (column.UseAllRows && i > 0)
                    writer.Write("</table></td><td><table class=\"wgrowspan\">");
                if (i == 0 || (i < sortedColumns.Length && column.NewRowInDetail))
                {
                    antcols = 0;
                    writer.Write("<tr class=\"wgrow\">");
                }
                if (!column.HideDetailTitle)
                {
                    ColumnHeader columnName = new ColumnHeader
                                        {
                                            m_VAlign = column.EditVAlign,
                                            m_Align = column.EditAlignTitle,
                                            m_ColumnWidth = column.WidthColumnTitle,
                                            m_Class = string.Format("{0} wgdetailheader", column.CssClassTitle),
                                            m_GridRowCount = (-1),
                                            m_GridId = grid.ID
                                        };
                    if (columnName.m_ColumnWidth == Unit.Empty)
                    {
                        int columnwidth = column.Title.Length * 12;

                        if (columnwidth > 140)
                            columnwidth = 140;
                        columnName.m_ColumnWidth = Unit.Pixel(columnwidth);
                    }
                    columnName.RenderBeginTag(writer, column, null,"<td");

                    if (string.IsNullOrEmpty(column.ToolTipEditTitle))
                        writer.Write(column.Title);
                    else
                        writer.Write(Tooltip.Add(column.Title, column.ToolTipEditTitle));

                    antcols++;

                    if (grid.BasicDetailLayout == false)
                        columnName.RenderEndTag(writer,"</td>");

                    if (grid.DisplayRequiredColumn)
                    {
                        antcols++;
                        ColumnHeader requiredColumn = new ColumnHeader
                                                {
                                                    m_Class =
                                                        string.Format("wgrequiredcolumn {0}", column.CssClassTitle),
                                                    m_ColumnWidth = Unit.Pixel(1),
                                                    m_VAlign =
                                                        (column.HeightEditableColumn.IsEmpty
                                                             ? column.EditVAlign
                                                             : VerticalPosition.top)
                                                };

                        requiredColumn.RenderBeginTag(writer, column, null,"<td");

                        if (column.Required && column.AllowEdit)
                            writer.Write(@"<span title=""{0}"" class=""ui-icon ui-icon-info""/>",
                                         grid.GetSystemMessage("Required"));
                        else
                            writer.Write("&nbsp;");

                        requiredColumn.RenderEndTag(writer, "</td>");
                    }
                }
                antcols++;
                if ((i == sortedColumns.Length - 1 || (i + 1 < sortedColumns.Length && grid[sortedColumns[i + 1]].NewRowInDetail)) && antcols < columnWidth)
                    grid.Rows[0][column.ColumnId].InternalCellSpan += columnWidth - antcols;

                //   column.Row = grid.MasterTable.Rows[0];
                column.Render(writer, grid.Rows[0][column.ColumnId]);

                if (i == sortedColumns.Length - 1 ||
                    (i + 1 < sortedColumns.Length &&
                     grid[sortedColumns[i + 1]].NewRowInDetail))
                {
                    writer.Write("</tr>");
                }

                if (column.UseAllRows)
                    if (i + 1 < sortedColumns.Length)
                        writer.Write("</table></td><td><table class=\"wgrowspan\">");
                    else
                        writer.Write("</table>");
                else if (allRowsColumns > 0 && i + 1 == sortedColumns.Length)
                    writer.Write("</table>");
            }
            if (allRowsColumns > 0)
                writer.Write("</td></tr></table></td></tr>");

            // Create tail
            if (string.IsNullOrEmpty(grid.GetToolbarHtml(ToolbarType.ToolbarDetailBottom)) == false)
            {
                if(grid.IsUsingJQueryUICSSFramework)
                    writer.Write(
                        "<tr class=\"ui-widget-header wgrow\"><td class=\"wgtoolbardetail\" colspan=\"{0}\">",
                        columnWidth);
                else

                writer.Write(
                    "<tr class=\"wgrow\"><td class=\"wgtoolbardetail\" colspan=\"{0}\">",
                    columnWidth);
                CreateDetailToolbar(grid.GetToolbarHtml(ToolbarType.ToolbarDetailBottom), writer, grid, editablecolumns);
                writer.Write("</td></tr>");
            }

            writer.Write("</table>");
        }
コード例 #5
0
ファイル: Rendering.cs プロジェクト: webgrid/WebGrid
        internal void RenderGrid(ref Grid grid, ref WebGridHtmlWriter writer)
        {
            string width = grid.Width.IsEmpty == false ? grid.Width.ToString() : "100%";
            /* cellpadding and cellspacing are fixed because CSS does not support similar behavior*/
            if (grid.IsUsingJQueryUICSSFramework)
                writer.Write(
                    "<table width=\"{0}\" id=\"{1}\" class=\"ui-widget-content\"  cellpadding=\"0\" cellspacing=\"0\">",
                    width, grid.ID);
            else
                writer.Write(
                    "<table width=\"{0}\" id=\"{1}\" cellpadding=\"0\" cellspacing=\"0\">",
                    width, grid.ID);
            int[] sortedColumns = grid.VisibleSortedColumns;

            if (grid.RecordsPerRow == 1)
            {
                //extra table is to get rid of css background glitch in ie and safari.
                if (grid.IsUsingJQueryUICSSFramework)
                    writer.Write("<thead class=\"ui-widget-header wgthead\">");
                else
                    writer.Write("<thead class=\"wgthead\">");
            }

            CreateTitle(grid, DisplayView.Grid, writer, sortedColumns, 0, "th");

            if ((grid.CollapseIfSlaveGrid && grid.ActiveMenuSlaveGrid != null) || grid.CollapsedGrid)
            {
                if (grid.RecordsPerRow == 1)
                    writer.Write("</thead></table>");
                else
                    writer.Write("</table>");
                return;
            }
            if (grid.MasterTable.Columns.Primarykeys == null)
            {
                grid.AllowDelete = false;
                grid.AllowEdit = false;
                grid.AllowNew = false;
                grid.AllowCopy = false;
            }
            if (string.IsNullOrEmpty(grid.GetToolbarHtml(ToolbarType.ToolbarGridTop)) == false)
            {
                if (grid.IsUsingJQueryUICSSFramework)
                    writer.Write("<tr class=\"ui-widget-header wgrow\"><td colspan=\"{0}\" class=\"wgtoolbargrid\">",
                                 sortedColumns.Length);
                else
                    writer.Write("<tr class=\"wgrow\"><td colspan=\"{0}\" class=\"wgtoolbargrid\">",
                                 sortedColumns.Length);
                CreateGridToolbar(grid.GetToolbarHtml(ToolbarType.ToolbarGridTop), writer, grid);
                writer.Write("</td></tr>");
            }
            // Show Header
            bool FilterByColumns = grid.MasterTable.Columns.Exists(delegate(Column column)
            { return column.FilterByColumnCollection != null && column.FilterByColumnCollection.Count > 0;});

            // Create column filter
            if (FilterByColumns)
                CreateFilterByColumns(grid, writer, sortedColumns);
            // RENDER ROWS

            if (grid.DisplayHeader)
            {
                // CREATE HEADING
                writer.Write("<tr valign=\"bottom\" class=\"wgrow wggridheader\" id=\"{0}r0\">", grid.ID);

                for (int ii = 0; ii < sortedColumns.Length; ii++)
                {
                    Column column = grid.MasterTable.Columns[sortedColumns[ii]];

                    ColumnHeader addcolumn = new ColumnHeader
                                                 {
                                                     m_Class = string.Format("{0} wgheadercell", column.CssClassTitle),
                                                     m_Align = column.GridAlign,
                                                     m_VAlign = VerticalPosition.bottom,
                                                     m_GridRowCount = (-1),
                                                     m_GridId = grid.ID
                                                 };
                    if ((column.ColumnType == ColumnType.SystemColumn &&
                         ((WebGrid.SystemColumn) column).SystemColumnType == SystemColumn.SpacingColumn) ==
                        false)
                    {
                        if (column.WidthColumnHeaderTitle == Unit.Empty)
                        {
                            switch (column.ColumnType)
                            {
                                case ColumnType.SystemColumn:
                                    addcolumn.m_ColumnWidth = Unit.Percentage(1);
                                    break;
                                case ColumnType.Decimal:
                                case ColumnType.Number:
                                    {
                                        int columnwidth = column.Title.Length*12;

                                        if (columnwidth > 200)
                                            columnwidth = 200;

                                        addcolumn.m_ColumnWidth = Unit.Pixel(columnwidth);
                                    }
                                    break;
                            }
                            //                                else
                            //                                    addcolumn.ColumnWidth = Unit.Pixel(100);
                        }
                        else
                            addcolumn.m_ColumnWidth = column.WidthColumnHeaderTitle;
                        grid[column.ColumnId].WidthColumnHeaderTitle = addcolumn.m_ColumnWidth;
                    }
                    addcolumn.RenderBeginTag(writer, column, null, "<th");
                    // writer.Write("<div class=\"wgheadercell\" id=\"{0}h{1}\">", grid.ID, column.ColumnId);

                    if (column.UseAllRows &&
                        (grid.SelectableRows || grid.RowHighLight != Color.Empty))
                    {
                        grid.RowHighLight = Color.Empty;
                        grid.SelectableRows = false;
                    }

                    if (column.IsInDataSource && column.Sortable)
                    {
                        string[] arrayParams = new string[1];
                        if (grid.MasterTable.DataSource != null)
                            arrayParams[0] = column.ColumnId;
                        else /*if (column.ColumnType == ColumnType.Foreignkey || !string.IsNullOrEmpty(grid.Sql))*/
                            arrayParams[0] = Interface.BuildTableElement(true, column.m_Table.DataSourceId,column.ColumnId);
                        /*else
                        {
                            Foreignkey fk = (Foreignkey) column;
                            arrayParams[0] =
                                Foreignkey.BuildDisplayTextSql(
                                    string.Format(" [_pk{0}_{1}].", sortedColumns[ii], fk.DataSourceId),
                                    fk.ValueColumn, string.Empty,
                                    true, fk.Table);
                            if (fk.Table.DataSource != null)
                                arrayParams[0] = fk.ColumnId;
                        }*/
                        string columnHeaderText = column.HeaderText;

                        if (string.IsNullOrEmpty(column.ToolTipGridHeaderText) == false)
                            columnHeaderText = Tooltip.Add(columnHeaderText, column.ToolTipGridHeaderText);

                        StringBuilder hyperlink;
                        if (!grid.AllowSort)
                            hyperlink = new StringBuilder(
                                String.Format("<span  class=\"{1}\">{0}</span>",
                                              columnHeaderText, null));
                        else
                        {

                            string sortimage = string.Empty;
                            // Up/down images
                            if (grid.DisplaySortIcons &&
                                grid.MasterTable.OrderBySortList[arrayParams[0]] != null)
                            {
                                /*StringBuilder img = new StringBuilder("sort-");
                                if (grid.MasterTable.OrderBySortList[arrayParams[0]].m_Desc)
                                    img.Append("down");
                                else
                                    img.Append("up");
                                if (grid.MasterTable.OrderBySortList[arrayParams[0]].m_DisplayIndex != 0)
                                    img.Append("2");
                                img.Append(".gif");

                                string sort =
                                    string.Format("&nbsp;<img style=\" border:0px\" alt=\"{0}\" src=\"{1}{2}\" />",
                                                  grid.GetSystemMessage("SortIcon"), grid.ImagePath, img);*/
                                if (grid.MasterTable.OrderBySortList[arrayParams[0]].m_Desc)
                                    sortimage = string.Format(
                                        @"<span title=""{0}"" style=""float:left""  class=""ui-icon ui-icon-triangle-1-s""/>",
                                        grid.GetSystemMessage("SortIcon"));
                                else
                                    sortimage = string.Format(
                                        @"<span title=""{0}"" style=""float:left"" class=""ui-icon ui-icon-triangle-1-n""/>",
                                        grid.GetSystemMessage("SortIcon"));
                            }
                            hyperlink = new StringBuilder("<table cellspacing=\"0\" cellpadding=\"0\"><tr><td>");
                            hyperlink.Append(new StringBuilder(
                                                 Buttons.Anchor(grid, columnHeaderText,
                                                                "ColumnHeaderClick", arrayParams, null,
                                                                null, null, null, false)));
                            hyperlink.Append("</td><td>");
                            hyperlink.Append(sortimage);
                            hyperlink.Append("</td></tr></table>");
                        }
                        if (grid.NonBreakingHeaders)
                        {
                            hyperlink.Insert(0, "<span class=\"wgnowrap\">");
                            hyperlink.Append("</span>");
                        }
                        writer.Write(hyperlink.ToString());
                    }
                    else
                    {
                        string css = string.Empty;
                        if (grid.NonBreakingHeaders)
                            css += " wgnowrap";
                        writer.Write("<span class=\"{0}\">{1}</span>", css, column.HeaderText);
                    }

                    addcolumn.RenderEndTag(writer, "</th>");
                }
                writer.Write("</tr>");
                // FINISH CREATE HEADING
            }
              if (grid.RecordsPerRow == 1)
                writer.Write("</thead>");

            bool tree = !string.IsNullOrEmpty(grid.TreeParentId);

            writer.Write(grid.BeforeRowsEvent());
            if (grid.Trace.IsTracing) grid.Trace.Trace("Started Rendering Rows ({0})", grid.ID);
            writer.Write("<tbody>");

            CreateRows(grid, tree, null, 0, writer, sortedColumns, 0);

            if (grid.RecordsPerRow == 1)
                CreateTotalSummary(grid, writer, sortedColumns);

            if (grid.Trace.IsTracing) grid.Trace.Trace("Stopped Rendering Rows ({0}).", grid.ID);
            writer.Write(grid.AfterRowsEvent());

            writer.Write("</tbody>");

            if (!string.IsNullOrEmpty(grid.GetToolbarHtml(ToolbarType.ToolbarGridBottom)))
            {
                writer.Write("<tfoot>");
                if (grid.IsUsingJQueryUICSSFramework)
                    writer.Write("<tr class=\"ui-widget-header wgrow\"><td colspan=\"{0}\" class=\"wgtoolbargrid\">",
                                 sortedColumns.Length);
                else
                    writer.Write("<tr class=\"wgrow\"><td colspan=\"{0}\" class=\"wgtoolbargrid\">",
                                 sortedColumns.Length);
                CreateGridToolbar(grid.GetToolbarHtml(ToolbarType.ToolbarGridBottom), writer, grid);
                writer.Write("</td></tr></tfoot>");
            }
            writer.Write("</table>");

            if (grid.Page != null)
                if (grid.EnableCallBack)
                    writer.Write("<input type=\"hidden\" id=\"{0}checkboxes\" name=\"{0}checkboxes\" value=\"{1}\" />",
                                 grid.ClientID, m_Checkboxlist.ToString());
                else
                    grid.Page.ClientScript.RegisterHiddenField(string.Format("{0}checkboxes", grid.ClientID),
                                                               m_Checkboxlist.ToString());
        }
コード例 #6
0
        internal static void CreateFilterByColumns(Grid grid, WebGridHtmlWriter writer, int[] sortedColumnID)
        {
            grid.m_RowsAdded++;
            writer.Write(
                grid.IsUsingJQueryUICSSFramework
                    ? "<tr class=\"ui-widget wgrow\" id=\"{0}r{1}\">"
                    : "<tr class=\"wgrow\" id=\"{0}r{1}\">", grid.ID, grid.m_RowsAdded);
            for (int ii = 0; ii < sortedColumnID.Length; ii++)
            {
                Column column = grid.MasterTable.Columns[sortedColumnID[ii]];
                if (column.FilterByColumnCollection.Count == 0)
                {
                    string columnstyle = string.Empty;
                    string columnId    = string.Format(" id=\"{0}{1}r{2}\"", grid.ID, column.ColumnId, grid.m_RowsAdded);
                    if (grid.MasterTable.Columns[column.ColumnId].WidthColumnHeaderTitle != Unit.Empty)
                    {
                        columnstyle =
                            string.Format("style=\"width: {0};\"",
                                          grid.MasterTable.Columns[column.ColumnId].WidthColumnHeaderTitle);
                    }
                    writer.Write("<th {0} {1}>&nbsp;</th>", columnstyle, columnId);
                    continue;
                }

                ColumnHeader addcolumn = new ColumnHeader
                {
                    m_Class       = string.Format("{0} wggridcell", column.CssClassTitle),
                    m_Align       = column.GridAlign,
                    m_VAlign      = VerticalPosition.bottom,
                    m_ColumnWidth =
                        grid.MasterTable.Columns[column.ColumnId].WidthColumnHeaderTitle,
                    m_GridRowCount = grid.m_RowsAdded,

                    m_GridId = grid.ID
                };

                addcolumn.RenderBeginTag(writer, column, null, "<th");

                string selectedValue = null;
                if (Grid.GotHttpContext &&
                    HttpContext.Current.Request.Form[string.Format("ddl{0}", column.ClientHeaderId)] != null)
                {
                    selectedValue =
                        HttpUtility.HtmlEncode(
                            HttpContext.Current.Request.Form[string.Format("ddl{0}", column.ClientHeaderId)]);
                    grid.State(string.Format("ddl{0}", column.ClientHeaderId), selectedValue);
                }
                else if (grid.GetState(string.Format("ddl{0}", column.ClientHeaderId)) != null)
                {
                    selectedValue = grid.GetState(string.Format("ddl{0}", column.ClientHeaderId)) as string;
                }
                bool isdate = false;
                if (grid.MasterTable.Columns[column.ColumnId].ColumnType == ColumnType.DateTime)
                {
                    isdate = true;
                }

                string eventScript = string.Empty;
                if (grid.Page != null)
                {
                    string link = grid.EnableCallBack && !column.ForcePostBack ? Asynchronous.GetCallbackEventReference(grid,
                                                                                                                        string.Format("ElementPostBack!ddl{0}",
                                                                                                                                      column.ColumnId), false,
                                                                                                                        string.Empty, string.Empty) : grid.Page.ClientScript.GetPostBackEventReference(grid,
                                                                                                                                                                                                       string.Format("ElementPostBack!ddl{0}",
                                                                                                                                                                                                                     column.ColumnId));
                    eventScript = string.Format(" onchange=\"{0}\" ", link);
                }
                string style = grid.MasterTable.Columns[column.ColumnId].WidthColumnHeaderTitle != Unit.Empty ? "class=\"wgeditfield wgselectbox \"" : " class=\"wgeditfield wgselectbox \" ";

                if (!isdate)
                {
                    StringBuilder dropdownbox = new StringBuilder("<select ");
                    dropdownbox.AppendFormat("{0} name=\"ddl{1}\" id=\"ddl{1}\" {2}><option value=\"\" selected=\"selected\">{3}</option>", style, column.ClientHeaderId, eventScript, column.Grid.GetSystemMessage("EmptySearchFilter"));

                    if (grid.Scripts == null || !grid.Scripts.DisableSelectMenu)
                    {
                        Grid.AddClientScript(writer, string.Format("$(document).ready(function() {{$('#ddl{0}').selectmenu({{maxHeight: {2},style:'dropdown',width: {1}}});}});", column.ClientHeaderId, column.WidthColumnHeaderTitle.Value, 400));
                    }


                    int i = 0;
                    while (i < column.FilterByColumnCollection.Count)
                    {
                        string _value = HttpUtility.HtmlEncode(column.FilterByColumnCollection[i]);
                        string _title = HttpUtility.HtmlEncode(column.FilterByColumnCollection.GetKey(i));
                        if (selectedValue != null && selectedValue == _value)
                        {
                            dropdownbox.AppendFormat("<option selected=\"selected\" value=\"{0}\">{1}</option>",
                                                     HttpUtility.HtmlEncode(column.FilterByColumnCollection[i]), _title);
                        }
                        else
                        {
                            dropdownbox.AppendFormat("<option value=\"{0}\">{1}</option>",
                                                     HttpUtility.HtmlEncode(column.FilterByColumnCollection[i]), _title);
                        }
                        i++;
                    }

                    writer.Write(dropdownbox);
                    writer.Write("</select> ");
                }
                else
                {
                    if (grid.DatabaseConnectionType != DataBaseConnectionType.SqlConnection)
                    {
                        throw new GridException(
                                  string.Format("'FilterByColumn' property for 'DateTime' ({0}) columns are only supported by 'SqlConnection' connection strings.", column.ColumnId));
                    }
                    writer.Write("<span style=\"white-space: nowrap;vertical-align:middle;\">");

                    string filter = ((WebGrid.DateTime)grid.MasterTable.Columns[column.ColumnId]).SearchFilter;

                    if (string.IsNullOrEmpty(filter))
                    {
                        StringBuilder s = new StringBuilder(string.Empty);
                        s.AppendFormat(
                            "<a class=\"wglinkfield\" href=\"?DateFilter={0}\">{1}</a>",
                            grid.MasterTable.Columns[column.ColumnId].ColumnId,
                            column.Grid.GetSystemMessage("DateTimeSearch"));
                        writer.Write(s);
                    }
                    else
                    {
                        StringBuilder s = new StringBuilder(string.Empty);
                        s.AppendFormat(
                            "<a class=\"wglinkfield\" href=\"#\"   onclick=\"javascript:WGdisableDateTimeSearch('{0}');\";return false;\">{1}</a>",
                            column.ColumnId, column.Grid.GetSystemMessage("DateTimeSearchReset"));
                        writer.Write(s);
                    }
                    // From date
                    writer.Write("</span>");
                }
                addcolumn.RenderEndTag(writer, "</th>");
            }

            writer.Write("</tr>");
        }
コード例 #7
0
ファイル: Rendering.cs プロジェクト: yuva2achieve/WebGrid
        internal static void RenderDetail(ref Grid grid, ref WebGridHtmlWriter writer)
        {
            string width = grid.Width.IsEmpty == false?grid.Width.ToString() : "100%";

            /* cellpadding and cellspacing are fixed because CSS does not support similar behavior*/
            if (grid.IsUsingJQueryUICSSFramework)
            {
                writer.Write( //ui-helper-reset
                    "<table width=\"{0}\" class=\"ui-widget-content  wgmaindetail\" cellspacing=\"0\" cellpadding=\"0\">", width);
            }
            else
            {
                writer.Write("<table width=\"{0}\" class=\"wgmaindetail\" cellspacing=\"0\" cellpadding=\"0\">", width);
            }

            int[] sortedColumns = grid.VisibleSortedColumns;

            int columnWidth    = -1;
            int allRowsColumns = 0;
            int ant            = 0;

            bool firstvisiblecolumn = true;

            bool editablecolumns = grid.m_Forceeditablecolumns;

            for (int i = 0; i < sortedColumns.Length; i++)
            {
                ant += 2;
                // if( Grid.BasicDetailLayout )
                //	 ant--;
                if (grid.DisplayRequiredColumn)
                {
                    ant++;
                }

                if (ant > columnWidth)
                {
                    columnWidth = ant;
                }

                Column c = grid.MasterTable.Columns[sortedColumns[i]];
                if (c.UseAllRows)
                {
                    allRowsColumns++;
                }
                if (c.IsVisible == false)
                {
                    continue;
                }
                if (editablecolumns == false && c.AllowEdit)
                {
                    editablecolumns = true;
                }
                if (firstvisiblecolumn)
                {
                    firstvisiblecolumn = false;
                    continue;
                }
                if (c.NewRowInDetail)
                {
                    ant = 0;
                }
            }
            // Create head
            CreateTitle(grid, DisplayView.Detail, writer, sortedColumns, columnWidth, "td");

            if ((grid.CollapseIfSlaveGrid && grid.ActiveMenuSlaveGrid != null) || grid.CollapsedGrid)
            {
                writer.Write("</table>");
                return;
            }
            // Create toolbar
            if (string.IsNullOrEmpty(grid.GetToolbarHtml(ToolbarType.ToolbarDetailTop)) == false)
            {
                if (grid.IsUsingJQueryUICSSFramework)
                {
                    writer.Write(
                        "<tr class=\"ui-widget-header wgrow\"><td class=\"wgtoolbardetail\" colspan=\"{0}\">",
                        columnWidth);
                }
                else
                {
                    writer.Write(
                        "<tr class=\"wgrow\"><td class=\"wgtoolbardetail\" colspan=\"{0}\">",
                        columnWidth);
                }
                CreateDetailToolbar(grid.GetToolbarHtml(ToolbarType.ToolbarDetailTop), writer, grid, editablecolumns);
                writer.Write("</td></tr>");
            }
            int antcols = 0;

            if (allRowsColumns > 0)
            {
                writer.Write(
                    "<tr><td colspan=\"{0}\"><table class=\"wgrowspan\"><tr valign=\"top\"><td><table class=\"wgrowspan\">",
                    columnWidth);
            }
            grid.MasterTable.Rows[0].RowIndex = -1;
            for (int i = 0; i < sortedColumns.Length; i++)
            {
                Column column = grid.MasterTable.Rows[0] != null ? grid.MasterTable.Columns[sortedColumns[i]] : grid.MasterTable.Columns[sortedColumns[i]];
                if (column.UseAllRows && i > 0)
                {
                    writer.Write("</table></td><td><table class=\"wgrowspan\">");
                }
                if (i == 0 || (i < sortedColumns.Length && column.NewRowInDetail))
                {
                    antcols = 0;
                    writer.Write("<tr class=\"wgrow\">");
                }
                if (!column.HideDetailTitle)
                {
                    ColumnHeader columnName = new ColumnHeader
                    {
                        m_VAlign       = column.EditVAlign,
                        m_Align        = column.EditAlignTitle,
                        m_ColumnWidth  = column.WidthColumnTitle,
                        m_Class        = string.Format("{0} wgdetailheader", column.CssClassTitle),
                        m_GridRowCount = (-1),
                        m_GridId       = grid.ID
                    };
                    if (columnName.m_ColumnWidth == Unit.Empty)
                    {
                        int columnwidth = column.Title.Length * 12;

                        if (columnwidth > 140)
                        {
                            columnwidth = 140;
                        }
                        columnName.m_ColumnWidth = Unit.Pixel(columnwidth);
                    }
                    columnName.RenderBeginTag(writer, column, null, "<td");

                    if (string.IsNullOrEmpty(column.ToolTipEditTitle))
                    {
                        writer.Write(column.Title);
                    }
                    else
                    {
                        writer.Write(Tooltip.Add(column.Title, column.ToolTipEditTitle));
                    }

                    antcols++;

                    if (grid.BasicDetailLayout == false)
                    {
                        columnName.RenderEndTag(writer, "</td>");
                    }

                    if (grid.DisplayRequiredColumn)
                    {
                        antcols++;
                        ColumnHeader requiredColumn = new ColumnHeader
                        {
                            m_Class =
                                string.Format("wgrequiredcolumn {0}", column.CssClassTitle),
                            m_ColumnWidth = Unit.Pixel(1),
                            m_VAlign      =
                                (column.HeightEditableColumn.IsEmpty
                                                             ? column.EditVAlign
                                                             : VerticalPosition.top)
                        };

                        requiredColumn.RenderBeginTag(writer, column, null, "<td");

                        if (column.Required && column.AllowEdit)
                        {
                            writer.Write(@"<span title=""{0}"" class=""ui-icon ui-icon-info""/>",
                                         grid.GetSystemMessage("Required"));
                        }
                        else
                        {
                            writer.Write("&nbsp;");
                        }

                        requiredColumn.RenderEndTag(writer, "</td>");
                    }
                }
                antcols++;
                if ((i == sortedColumns.Length - 1 || (i + 1 < sortedColumns.Length && grid[sortedColumns[i + 1]].NewRowInDetail)) && antcols < columnWidth)
                {
                    grid.Rows[0][column.ColumnId].InternalCellSpan += columnWidth - antcols;
                }

                //   column.Row = grid.MasterTable.Rows[0];
                column.Render(writer, grid.Rows[0][column.ColumnId]);

                if (i == sortedColumns.Length - 1 ||
                    (i + 1 < sortedColumns.Length &&
                     grid[sortedColumns[i + 1]].NewRowInDetail))
                {
                    writer.Write("</tr>");
                }

                if (column.UseAllRows)
                {
                    if (i + 1 < sortedColumns.Length)
                    {
                        writer.Write("</table></td><td><table class=\"wgrowspan\">");
                    }
                    else
                    {
                        writer.Write("</table>");
                    }
                }
                else if (allRowsColumns > 0 && i + 1 == sortedColumns.Length)
                {
                    writer.Write("</table>");
                }
            }
            if (allRowsColumns > 0)
            {
                writer.Write("</td></tr></table></td></tr>");
            }

            // Create tail
            if (string.IsNullOrEmpty(grid.GetToolbarHtml(ToolbarType.ToolbarDetailBottom)) == false)
            {
                if (grid.IsUsingJQueryUICSSFramework)
                {
                    writer.Write(
                        "<tr class=\"ui-widget-header wgrow\"><td class=\"wgtoolbardetail\" colspan=\"{0}\">",
                        columnWidth);
                }
                else
                {
                    writer.Write(
                        "<tr class=\"wgrow\"><td class=\"wgtoolbardetail\" colspan=\"{0}\">",
                        columnWidth);
                }
                CreateDetailToolbar(grid.GetToolbarHtml(ToolbarType.ToolbarDetailBottom), writer, grid, editablecolumns);
                writer.Write("</td></tr>");
            }

            writer.Write("</table>");
        }
コード例 #8
0
ファイル: Rendering.cs プロジェクト: yuva2achieve/WebGrid
        internal void RenderGrid(ref Grid grid, ref WebGridHtmlWriter writer)
        {
            string width = grid.Width.IsEmpty == false?grid.Width.ToString() : "100%";

            /* cellpadding and cellspacing are fixed because CSS does not support similar behavior*/
            if (grid.IsUsingJQueryUICSSFramework)
            {
                writer.Write(
                    "<table width=\"{0}\" id=\"{1}\" class=\"ui-widget-content\"  cellpadding=\"0\" cellspacing=\"0\">",
                    width, grid.ID);
            }
            else
            {
                writer.Write(
                    "<table width=\"{0}\" id=\"{1}\" cellpadding=\"0\" cellspacing=\"0\">",
                    width, grid.ID);
            }
            int[] sortedColumns = grid.VisibleSortedColumns;

            if (grid.RecordsPerRow == 1)
            {
                //extra table is to get rid of css background glitch in ie and safari.
                if (grid.IsUsingJQueryUICSSFramework)
                {
                    writer.Write("<thead class=\"ui-widget-header wgthead\">");
                }
                else
                {
                    writer.Write("<thead class=\"wgthead\">");
                }
            }

            CreateTitle(grid, DisplayView.Grid, writer, sortedColumns, 0, "th");

            if ((grid.CollapseIfSlaveGrid && grid.ActiveMenuSlaveGrid != null) || grid.CollapsedGrid)
            {
                if (grid.RecordsPerRow == 1)
                {
                    writer.Write("</thead></table>");
                }
                else
                {
                    writer.Write("</table>");
                }
                return;
            }
            if (grid.MasterTable.Columns.Primarykeys == null)
            {
                grid.AllowDelete = false;
                grid.AllowEdit   = false;
                grid.AllowNew    = false;
                grid.AllowCopy   = false;
            }
            if (string.IsNullOrEmpty(grid.GetToolbarHtml(ToolbarType.ToolbarGridTop)) == false)
            {
                if (grid.IsUsingJQueryUICSSFramework)
                {
                    writer.Write("<tr class=\"ui-widget-header wgrow\"><td colspan=\"{0}\" class=\"wgtoolbargrid\">",
                                 sortedColumns.Length);
                }
                else
                {
                    writer.Write("<tr class=\"wgrow\"><td colspan=\"{0}\" class=\"wgtoolbargrid\">",
                                 sortedColumns.Length);
                }
                CreateGridToolbar(grid.GetToolbarHtml(ToolbarType.ToolbarGridTop), writer, grid);
                writer.Write("</td></tr>");
            }
            // Show Header
            bool FilterByColumns = grid.MasterTable.Columns.Exists(delegate(Column column)
                                                                   { return(column.FilterByColumnCollection != null && column.FilterByColumnCollection.Count > 0); });

            // Create column filter
            if (FilterByColumns)
            {
                CreateFilterByColumns(grid, writer, sortedColumns);
            }
            // RENDER ROWS

            if (grid.DisplayHeader)
            {
                // CREATE HEADING
                writer.Write("<tr valign=\"bottom\" class=\"wgrow wggridheader\" id=\"{0}r0\">", grid.ID);

                for (int ii = 0; ii < sortedColumns.Length; ii++)
                {
                    Column column = grid.MasterTable.Columns[sortedColumns[ii]];

                    ColumnHeader addcolumn = new ColumnHeader
                    {
                        m_Class        = string.Format("{0} wgheadercell", column.CssClassTitle),
                        m_Align        = column.GridAlign,
                        m_VAlign       = VerticalPosition.bottom,
                        m_GridRowCount = (-1),
                        m_GridId       = grid.ID
                    };
                    if ((column.ColumnType == ColumnType.SystemColumn &&
                         ((WebGrid.SystemColumn)column).SystemColumnType == SystemColumn.SpacingColumn) ==
                        false)
                    {
                        if (column.WidthColumnHeaderTitle == Unit.Empty)
                        {
                            switch (column.ColumnType)
                            {
                            case ColumnType.SystemColumn:
                                addcolumn.m_ColumnWidth = Unit.Percentage(1);
                                break;

                            case ColumnType.Decimal:
                            case ColumnType.Number:
                            {
                                int columnwidth = column.Title.Length * 12;

                                if (columnwidth > 200)
                                {
                                    columnwidth = 200;
                                }

                                addcolumn.m_ColumnWidth = Unit.Pixel(columnwidth);
                            }
                            break;
                            }
                            //                                else
                            //                                    addcolumn.ColumnWidth = Unit.Pixel(100);
                        }
                        else
                        {
                            addcolumn.m_ColumnWidth = column.WidthColumnHeaderTitle;
                        }
                        grid[column.ColumnId].WidthColumnHeaderTitle = addcolumn.m_ColumnWidth;
                    }
                    addcolumn.RenderBeginTag(writer, column, null, "<th");
                    // writer.Write("<div class=\"wgheadercell\" id=\"{0}h{1}\">", grid.ID, column.ColumnId);

                    if (column.UseAllRows &&
                        (grid.SelectableRows || grid.RowHighLight != Color.Empty))
                    {
                        grid.RowHighLight   = Color.Empty;
                        grid.SelectableRows = false;
                    }

                    if (column.IsInDataSource && column.Sortable)
                    {
                        string[] arrayParams = new string[1];
                        if (grid.MasterTable.DataSource != null)
                        {
                            arrayParams[0] = column.ColumnId;
                        }
                        else /*if (column.ColumnType == ColumnType.Foreignkey || !string.IsNullOrEmpty(grid.Sql))*/
                        {
                            arrayParams[0] = Interface.BuildTableElement(true, column.m_Table.DataSourceId, column.ColumnId);
                        }

                        /*else
                         * {
                         *  Foreignkey fk = (Foreignkey) column;
                         *  arrayParams[0] =
                         *      Foreignkey.BuildDisplayTextSql(
                         *          string.Format(" [_pk{0}_{1}].", sortedColumns[ii], fk.DataSourceId),
                         *          fk.ValueColumn, string.Empty,
                         *          true, fk.Table);
                         *  if (fk.Table.DataSource != null)
                         *      arrayParams[0] = fk.ColumnId;
                         * }*/
                        string columnHeaderText = column.HeaderText;

                        if (string.IsNullOrEmpty(column.ToolTipGridHeaderText) == false)
                        {
                            columnHeaderText = Tooltip.Add(columnHeaderText, column.ToolTipGridHeaderText);
                        }



                        StringBuilder hyperlink;
                        if (!grid.AllowSort)
                        {
                            hyperlink = new StringBuilder(
                                String.Format("<span  class=\"{1}\">{0}</span>",
                                              columnHeaderText, null));
                        }
                        else
                        {
                            string sortimage = string.Empty;
                            // Up/down images
                            if (grid.DisplaySortIcons &&
                                grid.MasterTable.OrderBySortList[arrayParams[0]] != null)
                            {
                                /*StringBuilder img = new StringBuilder("sort-");
                                 * if (grid.MasterTable.OrderBySortList[arrayParams[0]].m_Desc)
                                 *  img.Append("down");
                                 * else
                                 *  img.Append("up");
                                 * if (grid.MasterTable.OrderBySortList[arrayParams[0]].m_DisplayIndex != 0)
                                 *  img.Append("2");
                                 * img.Append(".gif");
                                 *
                                 * string sort =
                                 *  string.Format("&nbsp;<img style=\" border:0px\" alt=\"{0}\" src=\"{1}{2}\" />",
                                 *                grid.GetSystemMessage("SortIcon"), grid.ImagePath, img);*/
                                if (grid.MasterTable.OrderBySortList[arrayParams[0]].m_Desc)
                                {
                                    sortimage = string.Format(
                                        @"<span title=""{0}"" style=""float:left""  class=""ui-icon ui-icon-triangle-1-s""/>",
                                        grid.GetSystemMessage("SortIcon"));
                                }
                                else
                                {
                                    sortimage = string.Format(
                                        @"<span title=""{0}"" style=""float:left"" class=""ui-icon ui-icon-triangle-1-n""/>",
                                        grid.GetSystemMessage("SortIcon"));
                                }
                            }
                            hyperlink = new StringBuilder("<table cellspacing=\"0\" cellpadding=\"0\"><tr><td>");
                            hyperlink.Append(new StringBuilder(
                                                 Buttons.Anchor(grid, columnHeaderText,
                                                                "ColumnHeaderClick", arrayParams, null,
                                                                null, null, null, false)));
                            hyperlink.Append("</td><td>");
                            hyperlink.Append(sortimage);
                            hyperlink.Append("</td></tr></table>");
                        }
                        if (grid.NonBreakingHeaders)
                        {
                            hyperlink.Insert(0, "<span class=\"wgnowrap\">");
                            hyperlink.Append("</span>");
                        }
                        writer.Write(hyperlink.ToString());
                    }
                    else
                    {
                        string css = string.Empty;
                        if (grid.NonBreakingHeaders)
                        {
                            css += " wgnowrap";
                        }
                        writer.Write("<span class=\"{0}\">{1}</span>", css, column.HeaderText);
                    }

                    addcolumn.RenderEndTag(writer, "</th>");
                }
                writer.Write("</tr>");
                // FINISH CREATE HEADING
            }
            if (grid.RecordsPerRow == 1)
            {
                writer.Write("</thead>");
            }

            bool tree = !string.IsNullOrEmpty(grid.TreeParentId);

            writer.Write(grid.BeforeRowsEvent());
            if (grid.Trace.IsTracing)
            {
                grid.Trace.Trace("Started Rendering Rows ({0})", grid.ID);
            }
            writer.Write("<tbody>");

            CreateRows(grid, tree, null, 0, writer, sortedColumns, 0);

            if (grid.RecordsPerRow == 1)
            {
                CreateTotalSummary(grid, writer, sortedColumns);
            }

            if (grid.Trace.IsTracing)
            {
                grid.Trace.Trace("Stopped Rendering Rows ({0}).", grid.ID);
            }
            writer.Write(grid.AfterRowsEvent());

            writer.Write("</tbody>");

            if (!string.IsNullOrEmpty(grid.GetToolbarHtml(ToolbarType.ToolbarGridBottom)))
            {
                writer.Write("<tfoot>");
                if (grid.IsUsingJQueryUICSSFramework)
                {
                    writer.Write("<tr class=\"ui-widget-header wgrow\"><td colspan=\"{0}\" class=\"wgtoolbargrid\">",
                                 sortedColumns.Length);
                }
                else
                {
                    writer.Write("<tr class=\"wgrow\"><td colspan=\"{0}\" class=\"wgtoolbargrid\">",
                                 sortedColumns.Length);
                }
                CreateGridToolbar(grid.GetToolbarHtml(ToolbarType.ToolbarGridBottom), writer, grid);
                writer.Write("</td></tr></tfoot>");
            }
            writer.Write("</table>");

            if (grid.Page != null)
            {
                if (grid.EnableCallBack)
                {
                    writer.Write("<input type=\"hidden\" id=\"{0}checkboxes\" name=\"{0}checkboxes\" value=\"{1}\" />",
                                 grid.ClientID, m_Checkboxlist.ToString());
                }
                else
                {
                    grid.Page.ClientScript.RegisterHiddenField(string.Format("{0}checkboxes", grid.ClientID),
                                                               m_Checkboxlist.ToString());
                }
            }
        }