gpt4 book ai didi

telerik-grid - RadGrid 在代码隐藏中应用过滤器

转载 作者:行者123 更新时间:2023-12-04 14:18:55 29 4
gpt4 key购买 nike

我正在尝试在下拉选择中为 RadGrid 的过滤器设置一个值。

GridColumn column = RadGrid1.MasterTableView.GetColumnSafe("versionId");
column.CurrentFilterFunction = GridKnownFunction.EqualTo;
column.CurrentFilterValue = VersionsCB.SelectedValue;
RadGrid1.Rebind();

这确实会在 versionId 过滤器框中填充版本,并将其设置为“EqualTo”,但不会过滤网格。我错过了什么?

编辑:aspx:
<telerik:RadGrid
ID="RadGrid1"
runat="server"
AllowFilteringByColumn="True"
AllowPaging="True"
AllowSorting="True"
AutoGenerateDeleteColumn="True"
AutoGenerateEditColumn="True"
DataSourceID="SqlDataSource1"
GridLines="None"
AllowAutomaticDeletes="True"
AllowAutomaticInserts="True"
AllowAutomaticUpdates="True"
PageSize="50"
Skin="Hay">

<ClientSettings>
<Scrolling AllowScroll="False" UseStaticHeaders="False" ScrollHeight="620"/>
</ClientSettings>

<MasterTableView DataSourceID="SqlDataSource1" AutoGenerateColumns="False" DataKeyNames="id" CommandItemDisplay="TopAndBottom">

<Columns>
<telerik:GridBoundColumn DataField="id" DataType="System.Int32" HeaderText="id" ReadOnly="True" SortExpression="id" UniqueName="id"></telerik:GridBoundColumn>
.
.
.
<telerik:GridBoundColumn DataField="versionId" DataType="System.Int32" HeaderText="versionId" ReadOnly="False" SortExpression="versionId" UniqueName="versionId"></telerik:GridBoundColumn>
</Columns>

</MasterTableView>

<HeaderContextMenu EnableImageSprites="True" CssClass="GridContextMenu GridContextMenu_Default"></HeaderContextMenu>

</telerik:RadGrid>

最佳答案

尝试这个:

RadGrid1.MasterTableView.FilterExpression = "([versionId] = "+VersionsCB.SelectedValue+")";    
GridColumn column = RadGrid1.MasterTableView.GetColumnSafe("versionId");
column.CurrentFilterFunction = GridKnownFunction.EqualTo;
column.CurrentFilterValue = VersionsCB.SelectedValue;
RadGrid1.Rebind();

在 .aspx 文件中修改您的 RadGrid 定义:
<telerik:RadGrid ID="RadGrid1" runat="server" EnableLinqExpressions="False" ...

关于telerik-grid - RadGrid 在代码隐藏中应用过滤器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5051322/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com