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

RadGrid filter and paging

3 Answers 140 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Matteo Beretta
Top achievements
Rank 1
Matteo Beretta asked on 19 May 2010, 12:14 AM

Hi, i have a management problem,

i have a grid that have a query as datasource, grid is enabled to filter and paging, when i filter, it filter for all pages, 

so the result is:

Page1 - result

Page2 - result etc etc

i want the it filtering for all the pages and then refresh the number of pages;

Now post some code because mi english is bad:

thank you.

<telerik:RadScriptManager runat="server" ID="Scipr"></telerik:RadScriptManager>  
 
<telerik:RadGrid runat="server" ID="rgrProva" Skin="Hay"   
        AutoGenerateColumns="false" AllowFilteringByColumn="true"  
        onpageindexchanged="rgrProva_PageIndexChanged" EnableLinqExpressions="false"  
        onneeddatasource="rgrProva_NeedDataSource" >  
 
    <PagerStyle Mode="NumericPages" />  
    <ClientSettings>  
    <Selecting  AllowRowSelect="true"/>  
    </ClientSettings>  
        <MasterTableView>  
            <Columns>  
            <telerik:GridNumericColumn UniqueName="colAnno" DataField="RIC.reqann">  
            </telerik:GridNumericColumn>  
            <telerik:GridNumericColumn UniqueName="colNumero" DataField="RIC.reqnum" FilterControlWidth="40px"   
            AutoPostBackOnFilter="false" CurrentFilterFunction="Contains" FilterDelay="4000" ShowFilterIcon="false">  
            </telerik:GridNumericColumn>  
            <telerik:GridBoundColumn UniqueName="colCliente" DataField="RIC.reqcli">  
            </telerik:GridBoundColumn>  
            </Columns>  
        </MasterTableView>  
</telerik:RadGrid> 

   protected void Page_Load(object sender, EventArgs e)  
        {  
                  
        }  
 
        private void _Load(int PageNumber)  
        {  
            rgrProva.AllowPaging = true;  
            rgrProva.PageSize = 15;  
            rgrProva.PagerStyle.Mode = GridPagerMode.NumericPages;  
            rgrProva.AllowCustomPaging = true;  
 
            FinitenessEntities context = new FinitenessEntities();  
 
            var qReq = from n in context.RICHIESTE  
                       orderby n.reqann, n.reqnum  
                       select new {RIC = n };  
 
            rgrProva.VirtualItemCount = qReq.Count();  
            rgrProva.DataSource = qReq.Skip(rgrProva.PageSize * PageNumber).Take(rgrProva.PageSize);  
        }  
 
        protected void rgrProva_PageIndexChanged(object source, Telerik.Web.UI.GridPageChangedEventArgs e)  
        {  
            this._Load(e.NewPageIndex);  
        }  
 
        protected void rgrProva_NeedDataSource(object source, GridNeedDataSourceEventArgs e)  
        {  
            this._Load(0);  
        } 

3 Answers, 1 is accepted

Sort by
0
Tsvetoslav
Telerik team
answered on 19 May 2010, 03:10 PM
Hello Matteo,

RadGrid supports out-of-the-box the scenario of filtering and paging you have described. However, if you do need to use custom paging, the following online example shoud guide you in that:
http://demos.telerik.com/aspnet-ajax/grid/examples/programming/custompaging/defaultcs.aspx

Hope it helps.

Greetings,
Tsvetoslav
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Carlos
Top achievements
Rank 1
answered on 12 Jan 2017, 02:50 PM

Hi all,

 

does anybody has the solution for, Matteo Beretta, problem i have the same problem, i think every body does.

- have paging working fine, and i have the filters of the radgrid.

- When i filter the rad grid, the paging mantains the number of pages it had before the filter.

e.g. if i have 100 pages of data, and filter, it will continue to show 100 pages even knowing that the filter only has twoo rows.

This is not custom paging problem, its something else

 

0
Konstantin Dikov
Telerik team
answered on 17 Jan 2017, 05:47 AM
Hi Carlos,

You can take a look at the implementation in the following online demo:
As you will notice in the code-behind, the custom paging is disabled when there are filter or sort expressions applied and this is due to the fact that the filtering and the sorting will be performed over the DataSource of the grid. 


Regards,
Konstantin Dikov
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
Grid
Asked by
Matteo Beretta
Top achievements
Rank 1
Answers by
Tsvetoslav
Telerik team
Carlos
Top achievements
Rank 1
Konstantin Dikov
Telerik team
Share this question
or