【问题标题】:Infragistics WebDataGrid- How do I get the value typed into the filter box by the user?Infragistics WebDataGrid-如何获取用户在过滤器框中输入的值?
【发布时间】:2013-05-22 19:50:52
【问题描述】:

使用 Infragistics WebDataGrid v11.2,我如何从 C# 代码隐藏中获取用户输入到过滤器框中的值?

说出列的 Key="LastName" 。在 webDataGrid 对输入的值执行搜索后,我想在下一个 PostBack 上使用 C# 获取在过滤器框中输入的字符串。

例如:

string ln = wdgNames.Columns.FindItemByKey("LastName").FilterValue ;

string ln = wdgNames.Rows[0]Items.FindItemByKey("LastName").FilterValue ;

【问题讨论】:

    标签: filter infragistics webdatagrid


    【解决方案1】:

    您需要处理网格DataFilteringDataFiltered 事件,在那里循环通过列过滤器(因为您可以拥有多个)并根据列类型获取过滤器值。

    例如,下面的代码可以访问字符串过滤器:

    using Infragistics.Web.UI;
    
    ...
    
    protected void grid_DataFiltering(object sender, GridControls.FilteringEventArgs e)
    {
       for (int I = 0; I < e.ColumnFilters.Count; I++) {
          if (e.ColumnFilters[I].ColumnType == "string") {
             //((GridControls.RuleTextNode)e.ColumnFilters[I].Condition).Value will give you the filter value
          }
       }
    
    }
    

    【讨论】:

    • 让它工作。奇怪的是,命名空间 GridControls 在 Visual Studio 中无法识别:GridControls.RuleTextNode(无法解析“GridControls”)但 RuleTextNode 使用:Infragistics.Web.UI.GridControls.RuleTextNode 或使用 RuleTextNode
    • @LillLansey 那是我的错,我假设 Infragistics.Web.UI 命名空间是通过 using 导入的——当使用长命名空间时,这是一个很好的捷径。
    • 还需要基于 o 的索引 (int I = 0; I
    • 有一个“使用Infragistics.Web.UI.GridControls;”文件中的声明。我想这就是为什么找到类 RuleTextNode 的原因。无论如何,谢谢。
    • 没问题,感谢指正。我将更新上面的代码,以便将来有人需要它是正确的
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-07-15
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多