Search code examples
asp.net-mvckendo-uikendo-asp.net-mvckendo-listview

How to bind Kendo ListView to Model and make it pageable


I have a Kendo ListView on my view like this:

@(Html.Kendo().ListView<SearchResultViewModel>(Model)
    .Name("searchResults")
    .TagName("div")            
    .DataSource(dataSource => {     
        dataSource.Model(model => model.Id("ID"));
        dataSource.PageSize(100);

    })
    .Pageable()    
    .Selectable()
)

Controller:

[HttpPost]
public ActionResult AdvancedSearch(AdvancedSearchViewModel criteria)
{
    // Get the search results (IEnumerable<SearchResultViewModel>)...
    var results = GetSearchResults(criteria);

    return View(results );
}

This ListView is inside a partial view on an Advanced Search page which sends the search criteria to the Controller via POST.

The Controller then returns the search results to the view using SearchResultsViewModel as the model.

The problem is the pagination does not work, and I know that that's because the pagination only works when there's an ajax call to the server to read the data. But, the problem is I can't using dataSource.Read to get the data via an ajax call, because as I said, the search criteria is inside a form and is sent to the controller via POST.

Now, the questions is how can I either make the pagination work without changing the data source, or read the data source using a POST method?


Solution

  • In the DataSource you should be able to add

    Datasource.ServerOperation(false) // this should enable paging on the client.