当前位置: 首页>>代码示例>>C#>>正文


C# Grid.GetState方法代码示例

本文整理汇总了C#中Grid.GetState方法的典型用法代码示例。如果您正苦于以下问题:C# Grid.GetState方法的具体用法?C# Grid.GetState怎么用?C# Grid.GetState使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Grid的用法示例。


在下文中一共展示了Grid.GetState方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetSelectedRows

        internal static void GetSelectedRows(Grid grid)
        {
            if (HttpContext.Current.Request[grid.ClientID + "checkboxes"] == null)
                return;

            StringBuilder oldRowsBuilder = new StringBuilder();

            if (grid.GetState("SelectedRows") != null)
                oldRowsBuilder.Append(grid.GetState("SelectedRows").ToString());
            StringBuilder selectedRowsBuilder = new StringBuilder();

            foreach (string request in HttpContext.Current.Request[grid.ClientID + "checkboxes"].Split('!'))
            {
                if (string.IsNullOrEmpty(request) == false)
                    oldRowsBuilder = new StringBuilder(oldRowsBuilder.ToString().Replace(request + "!", string.Empty));

                if (Grid.GotHttpContext && HttpContext.Current.Request[string.Format("{0}_{1}", grid.ClientID, request)] != null)
                    selectedRowsBuilder.AppendFormat("{0}!", request);
            }
            grid.State("SelectedRows", oldRowsBuilder + selectedRowsBuilder.ToString());
        }
开发者ID:webgrid,项目名称:WebGrid,代码行数:21,代码来源:MultiSelect.cs

示例2: CreateFilterByColumns

        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))
                    {
//.........这里部分代码省略.........
开发者ID:webgrid,项目名称:WebGrid,代码行数:101,代码来源:RenderingMethods.cs

示例3: IsInCookie

 /// <summary>
 /// Reads cookie for multiselect feature.
 /// If cookie exists and the cookie has a key value like the row identifier for WebGrid
 /// </summary>
 /// <param name="grid">The grid.</param>
 /// <param name="identifier">a unique identifier for a multiselect row.</param>
 /// <returns>
 /// Returns true if row is selected in the cookie, else false.
 /// </returns>
 internal static string IsInCookie(Grid grid, object identifier)
 {
     if (grid.GetState("SelectedRows") != null &&
         grid.GetState("SelectedRows").ToString().IndexOf(identifier + "!") > -1)
     {
         return grid.SelectRowColor != Color.Empty
                    ? string.Format("checked=\"checked\" onload=\"WGCheckboxhighlight(this,'{0}');\"",
                                    Grid.ColorToHtml(grid.SelectRowColor))
                    : "checked=\"checked\"";
     }
     return string.Empty;
 }
开发者ID:webgrid,项目名称:WebGrid,代码行数:21,代码来源:MultiSelect.cs

示例4: CanSaveGridToArray

        public void CanSaveGridToArray()
        {
            var setup = new[,] { { true, true, true }, { false, false, false }, { true, false, true } };

            var grid = new Grid(setup);
            Assert.That(grid.GetState(), Is.EqualTo(setup));
        }
开发者ID:JohnStov,项目名称:GameOfLife,代码行数:7,代码来源:GridTest.cs


注:本文中的Grid.GetState方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。