This question is locked. New answers and comments are not allowed.
Hello,
I'm trying to get from my data base only the data I need, not more.
I can have a lot of rows on my grid, so I don't want to get them all if not needed :
for example, if I have 5 pages of 10 lines, when I am on the first page, I just want to get the 5 first elements (#1 to 5) from my database. And if I go on the next page, I make an other querry to get the 5th following items (#6 to 10).
Here is what I have made, but I don't know how to pass the PageSize and the CurrentPageIndex of the grid to my controller. (I've put ??? in the following code)
(And here is My Binding Class
)
Thank you for your help
I'm trying to get from my data base only the data I need, not more.
I can have a lot of rows on my grid, so I don't want to get them all if not needed :
for example, if I have 5 pages of 10 lines, when I am on the first page, I just want to get the 5 first elements (#1 to 5) from my database. And if I go on the next page, I make an other querry to get the 5th following items (#6 to 10).
Here is what I have made, but I don't know how to pass the PageSize and the CurrentPageIndex of the grid to my controller. (I've put ??? in the following code)
...
@(Html.Telerik().Grid<MyCDSModel>() .Name("Grid") .Columns(columns => { ... }) .DataBinding(dataBinding => dataBinding.Ajax().Select("AjaxBinding", "MyController", new { PageSize = ???, CurrentPageIndex = ??? })) .Scrollable(scrolling => scrolling.Enabled(false)) .Sortable(sorting => sorting.Enabled(true)) .Pageable(pager => pager.Enabled(true)) .Pageable(pager => pager.Style(GridPagerStyles.Numeric | GridPagerStyles.NextPreviousAndDropDown)) .Filterable(filtering => filtering.Enabled(true)) .ClientEvents(events => events.OnLoad("onLoadGrid")) )
... (And here is My Binding Class
/// <summary>/// Ajax binding for the paging/// </summary>/// <returns>list of MyCDSModel</returns>[GridAction]public ActionResult AjaxBinding(int PageSize, int CurrentPageIndex) { List<MyObjects> = MyDataBase.GetAll().Skip(PageSize * CurrentPageIndex).Take(PageSize); return ...}Thank you for your help