filterpaginationtelerik-grid

Telerik DataSource, paging and filtering


I have a Telerik RadGrid. The initial DataSource that is bound to the grid has 145 records. I have filering turned on in the grid as well as paging and my pagesize is 20. When I filter down to 75 records, the MasterTableView.Items collection of the grid shows 20 records. This matches what's in the grid being displayed. However, I need to perform a Mass Change on the data and need the 75 filtered records. Is there somewhere in the Grid that has the 75 filtered records? I want to avoid having to get all 145 records again and then manually filtering.


Solution

  • Telerik doesn't provide a server side API to access filtered data in the grid, but there are a working around provided on their forum.

    The solution is to save filtered rows primary key while grid loading and then use IDs later to get your data.

    bool flag = false;
        protected void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e)
        {
           if (e.CommandName == RadGrid.FilterCommandName)
            {
                flag = true;
            }
        }
    
         protected void RadGrid1_PreRender(object sender, EventArgs e)
            {
               if (flag)
                {
                    foreach (GridDataItem grdItem in RadGrid1.Items)
                    {
                        int iID = Convert.ToInt32(grdItem.GetDataKeyValue("ID").ToString());
                        .  .   .   .
                    }
                    flag = false;
                }
            }
    

    for more information check the following link on telerik site: http://www.telerik.com/community/forums/aspnet/grid/how-to-get-filter-data.aspx