This is a migrated thread and some comments may be shown as answers.
Grid Paging Issue.
0 Answers 41 Views
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Top achievements
Rank 1
Raja asked on 01 Sep 2011, 08:20 PM
I am using Telerik grid in my MVC application using ajax binding.

Following is the code snippets:

            .DataBinding(dm => dm.Ajax()
                               .Select("Search", "CallSearch"))
            .ClientEvents(cEvnt => cEvnt.OnDataBinding("dataBinding").OnDataBound("dataBound"))
            .Columns(column =>
                column.Bound(o => o.CustomerLName).Title("Customer \nLast Name").Width(100).HeaderHtmlAttributes(new { @class="gridHeader" });
                column.Bound(o => o.CustomerFName).Title("Customer \nFirst Name").Width(100).HeaderHtmlAttributes(new { @class="gridHeader" });
                column.Bound(o => o.Chn_Desc).Title("Channel").Width(160).HeaderHtmlAttributes(new { @class="gridHeader" });
                column.Bound(o => o.StateFullName).Title("State").Width(80).HeaderHtmlAttributes(new { @class="gridHeader" });
                column.Bound(o => o.NumFiles).ClientTemplate("<a class='t-link' href='#' onClick='javascript:openAttachmentsWindow(<#= CallId #>)'; return false;> (<#= NumFiles #>)</a>").Title("Files").Width(30).HeaderHtmlAttributes(new { @class="gridHeader" });
            .Pageable(paging => paging.Style(GridPagerStyles.NextPreviousAndDropDown).PageSize(20, new int[]{10, 20, 50, 100}).Position(GridPagerPosition.Bottom))
            .Sortable(sort => sort.SortMode(GridSortMode.SingleColumn)).HtmlAttributes(new {style="width:100%"})
        public ActionResult Search(GridCommand command, int? categoryId, string searchFor, string searchForValue, int? issueId, int? stateId, string channel,string sortby, DateTime? fromDate, DateTime? toDate, int? callStatusId )
                       List<usp_SearchQuery_Result> searchQueryResults = context.Search(searchFor, searchForValue, categoryId, issueId, stateId, channel, fromDate, toDate, callStatusId);
            return View(new GridModel{ Data = searchQueryResults, Total = searchQueryResults.Count});

Following are my questions:
  1. Grid pageTo value is not set to page1 of the search results i.e If i search for calls and search result yileds 80 records and i select page 3 to view results and being on page 3 if i perform another search which gives only 5 records i expect the grid page to be 1 but it is defaulted to page 3 instead with no results displaying in page 3. User has to goto Page 1 to see the results.
  2. How to store grid related parameters like Page number selected by user and Sort criteria applied by user when user navigates to another page and comes back to the search page with previous search results. In this scenario this is not a new search criteria user is just going to another page and comming back to the search page using back button on the browser.

Asked by
Top achievements
Rank 1
Share this question