Hello Mark,
Here is a prototype of how you should implement the scenario: - based in the ID value (parsed from query string) find the record in all items, calculate the page index on which the item should appear and position the Grid to that page.
In order to implement this scenario you have two options:
1. Page the grid on client - the one which you are currently implementing. In order to implement this you have to load all data items in the data source, by setting .ServerOperation(false). Thus all data items will be served on client and you will be able to calculate the page index and page the Grid.
The cons of this is impementation:
- all data items will be served on client
- the widget will be initially bound to first page
2. Page the grid on server - parse the query string and calculate the page index on server. Here is how you could implement this:
- inside the controller - parse the query string and find the page index in all items. Then set the calculated value to a property in the ViewBag. Example:
public ActionResult Remote_Data_Binding()
{
ViewBag.Page = 5; //5 is result of the calculations
return View();
}
- configure the Grid for server operations - thus only page size items will be loaded on client
- set .AutoBind(false) to the Grid. Thus initial binding will be prevented
- add the following script which will bind the widget to the page calculated on server:
<script>
$(function() {
var dataSource = $("#grid").data("kendoGrid").dataSource;
var request = {
page: @ViewBag.Page,
pageSize: dataSource.pageSize(),
sort: dataSource.sort(),
filter: dataSource.filter(),
group: dataSource.group()
};
dataSource.query(request);
});
</script>
Regards,
Nikolay RusevTelerik