This is a migrated thread and some comments may be shown as answers.

Custom Paging, and filtering using NeedDataSource (Advance Binding)

0 Answers 191 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Chirag
Top achievements
Rank 1
Chirag asked on 07 May 2017, 10:18 AM

Hi,

In my application I want to display simple grid with paging and filtering functionality. I am using custom paging for pagination of the grid.

My NeedDataSoure look like this

protected void rgList_NeedDataSource(object sender, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
        {

 Meeting360Entities db = new Meeting360Entities();
       
            var query = from c in db.Committees
                        select c;
            
            var Data = query.ToList();
            rgList.DataSource = Data.Skip(rgList.CurrentPageIndex * rgList.PageSize).Take(rgList.PageSize); // This line will selects records need to display on screen.  
            rgList.VirtualItemCount = Data.Count;

}

Like my above code in want select filtered data from data base. So how can in add WHERE clause into my linq query.

     <telerik:RadGrid ID="rgList" runat="server" AutoGenerateColumns="false" OnItemCommand="rgList_ItemCommand" GridLines="None"  
                                    ClientSettings-EnableRowHoverStyle="true" PagerStyle-Position="Bottom" AllowPaging="True" AllowCustomPaging ="true" PageSize="10" OnNeedDataSource="rgList_NeedDataSource"
                                    AllowFilteringByColumn="true">
                                    <MasterTableView DataKeyNames="CommitteeID" ClientDataKeyNames="CommitteeID">
                                        <Columns>
                                            <telerik:GridBoundColumn DataField="CommitteeID" HeaderText="CommitteeID" UniqueName="CommitteeID" Visible="false">
                                            </telerik:GridBoundColumn>
                                            <telerik:GridBoundColumn DataField="Name" HeaderText="Name" SortExpression="Name" UniqueName="Name" CurrentFilterFunction="Contains" AutoPostBackOnFilter="true" ShowFilterIcon="false">
                                            </telerik:GridBoundColumn>
                                            <telerik:GridTemplateColumn>
                                                <ItemTemplate>
                                                    <telerik:RadButton ID="btnEdit" runat="server" CommandArgument='<% #Eval("CommitteeID")%>' CommandName="ItemEdit" Text="Edit"></telerik:RadButton>
                                                </ItemTemplate>
                                            </telerik:GridTemplateColumn>
                                        </Columns>
                                    </MasterTableView>
                                    <ClientSettings>
                                        <Selecting AllowRowSelect="true"></Selecting>
                                    </ClientSettings>
                                </telerik:RadGrid>

No answers yet. Maybe you can help?

Tags
Grid
Asked by
Chirag
Top achievements
Rank 1
Share this question
or