Hi,
I have a Kendo grid on a page that is created using this code in my cshtml file
@(Html.Kendo().Grid<Entity>()
.Name("productsGrid")
.Columns(columns =>
{
columns.Bound(schema => schema.Ns).Width(150)
.Filterable(false).Sortable(false);
columns.Bound(schema => schema.Name).Title("Entity Name").Width(250);
columns.Bound(schema => schema.Desc).Title("Description")
.ClientTemplate("#= preserveDirtyFlag(data, data.Desc) #")
.Filterable(false).Sortable(false);
})
.Editable(editable => editable.Mode(GridEditMode.InCell))
.Sortable()
.DataSource(dataSource => dataSource
.Ajax()
.Batch(true)
.ServerOperation(true)
.PageSize(100)
.Model(model =>
{
model.Id(entity => entity.Id);
model.Field(entity => entity.Ns).Editable(false);
model.Field(entity => entity.Name).Editable(false);
model.Field(entity => entity.Desc);
})
.Read(read => read.Action("GetEntityList", "Products").Data("getQuery"))
.Events(e => e.RequestStart("onPageChange"))
)
.Events(e => e.DataBound("onDataBound"))
.ClientDetailTemplateId("fieldDescriptions")
)
Everything works perfectly fine on first load.
The pagination works perfectly (have removed the code for that from above). Even the filtering works smoothly. super smooth.
The only issue is with sorting.
---
As the code shows that sorting is enabled on the single column: 'Entity name'
As soon as that column title is clicked in order to sort the data, the browser redirects to a new URL
earlier it was at
/CatalogManager/Descriptions
but after clicking on the 'Entity Name' in order to sort that table, it redirects to:
/CatalogManager/Descriptions/GetEntityList?sortField=Relevancy&sortFieldValue=_score&descriptionsGrid-sort=Name-desc
and then shows the pure JSON output that the GetEntityList controller returns instead of rendering in the grid.
Why does filtering and pagination work well but sorting breaks the page?
---
The amazing thing is, if I remove the '/GetEntityList' from the url manually and just navigate to:
/CatalogManager/Descriptions?sortField=Relevancy&sortFieldValue=_score&descriptionsGrid-sort=Name-desc
Then the table is displayed in its full glory sorted by the required field. So they question is, why does it navigate to the API url and display the raw JSON data in the first place?