简体   繁体   English

通过分页在RadGrid Telerik中查找记录

[英]Finding records in RadGrid Telerik with pagination

How is it possible to find given record by key in the radGrid when pagination is enabled ? 启用分页时,如何通过radGrid中的键查找给定记录? After insert of an element I would like to select new row that why I need this functionality. 插入元素后,我想选择新行,这就是为什么我需要此功能的原因。

thanks for any help 谢谢你的帮助

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

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

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

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. 一种方法是禁用分页,然后进行Rebind ,然后遍历所有项目,找到该项目应位于的页面,然后启用分页。 The other way is to make separate Rebind per page, like this: 另一种方法是使每页单独重新Rebind ,如下所示:

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. 有关更多信息和示例,请查看Telerik论坛。 This links are useful: 该链接非常有用:

Here is a link from Telerik that will select the Last Updated, or Last Inserted row. 这是Telerik的链接,它将选择“上次更新”或“上次插入”行。

Select last Updated or Inserted row in Telerik RadGrid 选择Telerik RadGrid中的最后更新或插入的行

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM