如何过滤 Telerik 的 RadGrid 的 GridTemplateColumns
我的 RadGrid
中有两个 GridTemplateColumn
。默认过滤对我不起作用,我想更改它。
GridTemplateColumns 如下所示:
<telerik:GridTemplateColumn FilterControlAltText="Filter Online column" HeaderText="Online"
UniqueName="Online">
<ItemTemplate>
<asp:CheckBox ID="chkOnline" runat="server" Checked='<%# CheckForOnline(Eval("ID")) %>'
Enabled="False" />
</ItemTemplate>
<HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" />
<ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" Width="100px" />
</telerik:GridTemplateColumn>
另一个:
<telerik:GridTemplateColumn FilterControlAltText="Filter FileSize column" HeaderText="FileSize"
UniqueName="FileSize" Visible="False">
<ItemTemplate>
<asp:Label ID="lblFileSize" runat="server" Text='<%# Eval("FileSize") %>'></asp:Label>
</ItemTemplate>
<HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" />
<ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn FilterControlAltText="Filter FileSizeChange column" HeaderText="FileSize"
UniqueName="FileSizeChange">
<ItemTemplate>
<asp:Label ID="lblFileSizeChange" runat="server" Text='<%# ChangeFileSize(Eval("FileSize")) %>'></asp:Label>
</ItemTemplate>
<HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" />
<ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
</telerik:GridTemplateColumn>
如您所见, FileSize
TemplateColumn
已禁用,我正在使用 FileSizeChange
代替。
FileSize 字符串就像 (213435) ->这个数字显示了我们的字节数。 FileSizeChange 就像 (231 MB)/
如何为 Online
和 FileSizeChange
GridTemplateColumn
编写过滤?
I have two GridTemplateColumn
s in my RadGrid
. The default filtering doesn't work for me and I want to change it.
The GridTemplateColumns are like below:
<telerik:GridTemplateColumn FilterControlAltText="Filter Online column" HeaderText="Online"
UniqueName="Online">
<ItemTemplate>
<asp:CheckBox ID="chkOnline" runat="server" Checked='<%# CheckForOnline(Eval("ID")) %>'
Enabled="False" />
</ItemTemplate>
<HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" />
<ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" Width="100px" />
</telerik:GridTemplateColumn>
and the other one:
<telerik:GridTemplateColumn FilterControlAltText="Filter FileSize column" HeaderText="FileSize"
UniqueName="FileSize" Visible="False">
<ItemTemplate>
<asp:Label ID="lblFileSize" runat="server" Text='<%# Eval("FileSize") %>'></asp:Label>
</ItemTemplate>
<HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" />
<ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn FilterControlAltText="Filter FileSizeChange column" HeaderText="FileSize"
UniqueName="FileSizeChange">
<ItemTemplate>
<asp:Label ID="lblFileSizeChange" runat="server" Text='<%# ChangeFileSize(Eval("FileSize")) %>'></asp:Label>
</ItemTemplate>
<HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" />
<ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
</telerik:GridTemplateColumn>
As you can see, FileSize
TemplateColumn
is disabled and I am using FileSizeChange
instead.
FileSize string is like (213435) -> this number shows us bytes. FileSizeChange is like (231 MB)/
How can I write filtering for both Online
and FileSizeChange
GridTemplateColumn
s?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
为了在模板列上使用过滤,您需要设置DataField并将数据字段添加到DataKeyNames,
例如:
In order to use filtering on a Template column you need to set the DataField and add the datafield to the DataKeyNames
eg:
如果您需要对项目模板列进行过滤,请确保在项目模板列上设置以下属性:
DataField="FileSize"
允许过滤=“真”
自动PostBackOnFilter =“真”
DataType="System.String"
如果要隐藏过滤功能图标,这两个是可选的:
ShowFilterIcon =“假”
CurrentFilterFunction="Contains"
另外请确保您的 radgrid 上启用了过滤。
这是一篇关于它的好文章:
http://www.telerikschool.com/2011/11/textbox-in -gridtemplatecolumn.html
If you need filtering on an item template column make sure you set the following properties on the item template column:
DataField="FileSize"
AllowFiltering="true"
AutoPostBackOnFilter="true"
DataType="System.String"
These two are optional if you want to hide the filter function icon:
ShowFilterIcon="false"
CurrentFilterFunction="Contains"
Also make sure you have filtering enabled on your radgrid.
Here's a good post about it:
http://www.telerikschool.com/2011/11/textbox-in-gridtemplatecolumn.html
由于这是您手动构建的 ItemTemplate,因此您需要手动过滤。请参阅 Telerik 文档的此页面: http ://www.telerik.com/help/aspnet-ajax/grid-operate-with-filter-expression-manually.html
Because this is an ItemTemplate that you're building manually, you will need to filter manually. See this page of the Telerik docs: http://www.telerik.com/help/aspnet-ajax/grid-operate-with-filter-expression-manually.html