rad网格中的过滤选项 [英] Filtering option in rad grid

查看:57
本文介绍了rad网格中的过滤选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我正在尝试在RadGrid中实现过滤器选项。但我无法做到这一点。

每当我过滤网格时,网格数据就会消失。这个网格我动态绑定。



这是代码:



Hi all,
I am trying to implement filter option in my RadGrid. But I am unable to do that.
Whenever I am filtering the grid, the data of grid goes off. This grid I binded dynamically.

Here is the code:

<telerik:RadGrid runat="server" ID="rgBooks" AllowPaging="True"

                AllowSorting="True" AutoGenerateColumns="False"

                onpageindexchanged="rgBooks_PageIndexChanged"

                onpagesizechanged="rgBooks_PageSizeChanged" CellSpacing="0"

                GridLines="None" oneditcommand="rgBooks_EditCommand"

                ongroupschanging="rgBooks_GroupsChanging" onsortcommand="rgBooks_SortCommand"

                ShowGroupPanel="True" oncancelcommand="rgBooks_CancelCommand"

                onitemupdated="rgBooks_ItemUpdated"

                onupdatecommand="rgBooks_UpdateCommand"

                ondeletecommand="rgBooks_DeleteCommand" oninsertcommand="rgBooks_InsertCommand"

                onitemcommand="rgBooks_ItemCommand" AllowFilteringByColumn="True"  >

                <ClientSettings AllowDragToGroup="True">
                    <Selecting CellSelectionMode="None"></Selecting>
                </ClientSettings>
                <MasterTableView CommandItemDisplay="Bottom" AllowFilteringByColumn="true">

                    <RowIndicatorColumn Visible="True" FilterControlAltText="Filter RowIndicator column"/>
                    <ExpandCollapseColumn Visible="True" FilterControlAltText="Filter ExpandColumn column"/>
                    <Columns>
                        <telerik:GridTemplateColumn HeaderText="Book ID" DataField="BookID" UniqueName="BookID" CurrentFilterFunction="EqualTo" AutoPostBackOnFilter="true" DataType="System.Int32" >
                            <ItemTemplate>
                                <asp:Label ID="lblBookID" runat="server" Text='<%#Eval("BookID") %>' />
                            </ItemTemplate>
                        </telerik:GridTemplateColumn>
                        <telerik:GridTemplateColumn HeaderText="Title" UniqueName="Title">
                            <ItemTemplate>
                                <asp:Label ID="lblTitle" runat="server" Text='<%#Eval("Title") %>' />
                            </ItemTemplate>
                            <EditItemTemplate>
                                <asp:TextBox ID="txtTitle" runat="server" Text='<%#Eval("Title") %>' />
                                <asp:RequiredFieldValidator ID="rfvTitle" runat="server" ForeColor="Red"

                                    ErrorMessage="Please Enter the Title" ControlToValidate="txtTitle"/>
                            </EditItemTemplate>
                        </telerik:GridTemplateColumn>
                        <telerik:GridTemplateColumn HeaderText="Publisher Name" UniqueName="PublisherName" >
                            <ItemTemplate>
                                <asp:Label ID="lblPublisherName" runat="server" Text='<%#Eval("PublisherName") %>' />
                            </ItemTemplate>
                            <EditItemTemplate>
                                <asp:TextBox ID="txtPublisherName" runat="server" Text='<%#Eval("PublisherName") %>' />
                                <asp:RequiredFieldValidator ID="rfvPublisherName" runat="server" ForeColor="Red"

                                    ErrorMessage="Please Enter the Publisher Name" ControlToValidate="txtPublisherName"/>
                            </EditItemTemplate>
                        </telerik:GridTemplateColumn>
                        <telerik:GridTemplateColumn HeaderText="Published Date" UniqueName="PublishedDate">
                            <ItemTemplate>
                                <asp:Label ID="lblPublishedDate" runat="server" Text='<%#Eval("PublishedDate") %>' />
                            </ItemTemplate>
                            <EditItemTemplate>
                                 <asp:TextBox ID="txtPublishedDate" runat="server" Text='<%#Eval("PublishedDate") %>'

                                    onKeyPress='Javascript:return false;'/>
                                 <cc1:CalendarExtender ID="cePublishedDate" TargetControlID="txtPublishedDate"

                                    runat="server"/>
                            </EditItemTemplate>
                        </telerik:GridTemplateColumn>
                        <telerik:GridEditCommandColumn UniqueName="EditCommandColumn"

                            HeaderText="Edit" ButtonType="ImageButton"/>
                        <telerik:GridButtonColumn ConfirmText="Are You Sure Want To Delete?" ConfirmDialogType="Classic"

                            ConfirmTitle="Delete" ButtonType="ImageButton" CommandName="Delete" Text="Delete"

                            UniqueName="DeleteRow" HeaderText="Delete" CommandArgument="BookID">
                            <ItemStyle HorizontalAlign="Center" />
                        </telerik:GridButtonColumn>
                    </Columns>
                    <CommandItemSettings AddNewRecordText="Add New" ShowRefreshButton="true" RefreshText="Refresh" />
                        <CommandItemStyle Height="30px" />
                    <EditFormSettings>
                        <EditColumn UniqueName="EditCommand" />
                    </EditFormSettings>
                </MasterTableView>
                <FilterMenu EnableImageSprites="False"></FilterMenu>
            </telerik:RadGrid>





Please help me out of this proble m.

Thanx in advance..



Please help me out of this problem.
Thanx in advance..

推荐答案

see if this might help you (from codeproject)



Filter a DataGrid using a Foreign Key Combobox[^]
see if this might help you (from codeproject)

Filter a DataGrid using a Foreign Key Combobox[^]


Just Add NeedDataSorceEvent of RadGrid and keep all code which are using in binding radgrid except Radgrid1.databind()



and set on aspx page allowfilteringcolumn=true;
Just Add NeedDataSorceEvent of RadGrid and keep all code which are using in binding radgrid except Radgrid1.databind()

and set on aspx page allowfilteringcolumn=true;


这篇关于rad网格中的过滤选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆