Exemplo n.º 1
0
        /// <summary>
        ///  This function renders sort icon on the basis of
        ///  passed direction and visibility by the caller.
        /// </summary>
        private static void RenderSortIcon(HtmlTextWriter writer, SortExpression sortExpr, int?sequence)
        {
            SortDirection dir = sortExpr.GetSortDirection();

            if (dir == SortDirection.Ascending)
            {
                //_btnIcon.CustomIconName = " ui-icon-triangle-1-n";
                ButtonEx.RenderIcon(writer, "ui-icon-triangle-1-n");
            }
            else
            {
                //_btnIcon.CustomIconName = " ui-icon-triangle-1-s";
                ButtonEx.RenderIcon(writer, "ui-icon-triangle-1-s");
            }

            //_btnIcon.RenderControl(writer);
            // Dynamically replaced with sort sequence
            writer.RenderBeginTag(HtmlTextWriterTag.Sup);
            writer.Write(sequence);
            writer.RenderEndTag();      // sup
        }
Exemplo n.º 2
0
        /// <summary>
        /// Master row markup looks like:
        /// <tr>
        ///   <td colspan="x">
        ///     <table>
        ///     <tbody>
        ///       <tr>
        ///         <td>Header Text 1: Header Value 1</td>
        ///         ...
        ///       </tr>
        ///       </tbody>
        ///     </table>
        ///   </td>
        /// </tr>
        /// </summary>
        /// <remarks>
        /// The method renders the content of <c>GridViewExMasterRow</c> with in gridview header using custom HTML table.
        /// </remarks>
        private void RenderMasterRowHeader(HtmlTextWriter writer)
        {
            // Render the master row before we render the normal row
            if (_rowInfo._masterRowIndex != 0)
            {
                // We are not the first master row.
                // Enclose the rows of this master in a seperate tbody for ease of scripting
                writer.Write("</tbody><tbody>");
            }
            writer.AddAttribute(HtmlTextWriterAttribute.Class, "gvex-masterrow ui-widget-content");
            writer.RenderBeginTag(HtmlTextWriterTag.Tr);

            writer.AddStyleAttribute(HtmlTextWriterStyle.TextAlign, "right");
            writer.AddStyleAttribute(HtmlTextWriterStyle.WhiteSpace, "nowrap");
            writer.RenderBeginTag(HtmlTextWriterTag.Td);
            writer.Write("{0:N0}&nbsp;", _rowInfo._masterRowIndex + 1);

            /*
             * <A class="ui-button ui-widget ui-state-default ui-corner-all ui-button-icon-only">
             * <SPAN class="ui-button-icon-primary ui-icon ui-icon-gear" />
             * <SPAN class=ui-button-text>Hello</SPAN>
             *
             */
            //Folder icon here
            writer.RenderBeginTag(HtmlTextWriterTag.Sup);
            ButtonEx.RenderIcon(writer, "ui-icon-folder-open");
            writer.RenderEndTag();      // sup;
            writer.RenderEndTag();      //td

            // Here are aggregating the column spans of each visible header cell. If the column span is 0, we
            // treat it as 1.
            int visibleColumnCount = this.Grid.HeaderRow.Cells.Cast <DataControlFieldHeaderCell>()
                                     .Where(p => p.Visible)
                                     .Aggregate(0, (total, next) => total + (next.ColumnSpan == 0 ? 1 : next.ColumnSpan));


            // Subtract 2 for the first and last columns
            int nColSpan = visibleColumnCount - 2;

            writer.AddAttribute(HtmlTextWriterAttribute.Colspan, nColSpan.ToString());
            writer.RenderBeginTag(HtmlTextWriterTag.Td);

            int i = 0;

            foreach (int masterIndex in this.Grid.MasterColumnIndexes.OrderBy(p => p))
            {
                DataControlField col = this.Grid.Columns[masterIndex];
                SortExpression   colSortExpression = new SortExpression(col.SortExpression);
                int nSortIndex = this.Grid.SortExpressions.Select((p, index) => p.Equals(colSortExpression) ? index : -1)
                                 .Single(p => p != -1);
                SortDirection dirIcon = colSortExpression.GetSortDirection();
                col.ItemStyle.AddAttributesToRender(writer);
                writer.AddAttribute(HtmlTextWriterAttribute.Class, "header-entry");
                TableCell cell = this.Cells[masterIndex];
                if (cell.HasControls())
                {
                    // Ignore header text
                    writer.RenderBeginTag(HtmlTextWriterTag.Div);
                    foreach (Control ctl in cell.Controls)
                    {
                        ctl.RenderControl(writer);
                    }
                    writer.RenderEndTag();  // div
                }
                else
                {
                    writer.RenderBeginTag(HtmlTextWriterTag.Span);
                    if (string.IsNullOrEmpty(col.HeaderText))
                    {
                        writer.Write(cell.Text);
                    }
                    else
                    {
                        writer.RenderBeginTag(HtmlTextWriterTag.Strong);
                        GridViewExHeaderCell.RenderNotSortableWithIcon(writer, col.HeaderText, dirIcon, nSortIndex + 1);
                        writer.RenderEndTag();  // strong
                        writer.Write(": {0}", cell.Text);
                    }
                    writer.RenderEndTag();  // span
                }
                ++i;
                if (i % 2 == 0)
                {
                    writer.WriteBreak();
                }
            }

            writer.RenderEndTag();      //td

            // Row count
            writer.AddStyleAttribute(HtmlTextWriterStyle.TextAlign, "right");
            writer.RenderBeginTag(HtmlTextWriterTag.Td);
            writer.Write("{0:N0} row{1}", _rowInfo._countRowsInMaster, _rowInfo._countRowsInMaster == 1 ? "" : "s");
            writer.RenderEndTag();
            writer.RenderEndTag();      //tr
        }