Finding records in RadGrid Telerik with pagination

混江龙づ霸主 提交于 2019-12-11 04:06:29

问题


How is it possible to find given record by key in the radGrid when pagination is enabled ? After insert of an element I would like to select new row that why I need this functionality.

thanks for any help


回答1:


One way is to disable paging, then make a Rebind, then iterate through all the items, find the page the item should be in and then enable paging. The other way is to make separate Rebind per page, like this:

int count = RadGrid1.MasterTableView.PageCount;  
for (int i = 0; i < count; i++) 
{ 
    RadGrid1.CurrentPageIndex = i; 
    RadGrid1.Rebind();

    foreach (GridDataItem dataItem in RadGrid1.Items) 
    { 
        var yourID = dataItem.GetDataKeyValue("YourID"); 
        if (yourID == insertedItemID)
           break;
    }  
}     
RadGrid1.Rebind(); 

For more info and an example, check the Telerik forums. This links are useful:

  • RadGrid - select row on other page
  • How to count selected items in RadGrid
  • Getting total number of rows in a grid



回答2:


Here is a link from Telerik that will select the Last Updated, or Last Inserted row.

Select last Updated or Inserted row in Telerik RadGrid




回答3:


RadGrid1.AllowPaging = false;
RadGrid1.Rebind();

foreach (GridDataItem dataItem in RadGrid1.Items) 
{ 
    var yourID = dataItem.GetDataKeyValue("YourID"); 
    if (yourID == insertedItemID)
       break;
}  

RadGrid1.AllowPaging = true; RadGrid1.Rebind();



来源:https://stackoverflow.com/questions/8646219/finding-records-in-radgrid-telerik-with-pagination

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!