This question is locked. New answers and comments are not allowed.
I am using Telerik grid in my MVC application using ajax binding.
Following is the code snippets:
Following are my questions:
Following is the code snippets:
Html.Telerik().Grid(Model)
.Name("SearchResults")
.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%"})
.Render();
[HttpPost]
[GridAction]
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:
- 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.
- 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.