Hi. I'm pretty new to the Kendo controls so hopefully I'm just missing something obvious here.
First question: How do I apply a descending sort by default on a grid? Here's my current grid definition but the sort (by date_time) is ascending rather than descending:
I
Second question: The sort option doesn't seem to be reaching the MVC action.
If I look at the form or add a "sort" string param to the Query function I can see the sort information being passed (e.g. "site_name-asc") but it isn't being pulled into the request object.
From another thread I found I saw a recommendation to make sure kendo.aspnetmvc.min.js is included but I checked and it is.
What else should I check?
First question: How do I apply a descending sort by default on a grid? Here's my current grid definition but the sort (by date_time) is ascending rather than descending:
@(Html.Kendo().Grid<DSG.Support.EntityModel.Models.SolutionFeedback>()
.Name(
"KBFeedbackGrid"
)
.Columns(columns =>
{
columns.Bound(
"solution_id"
).Title(
"KB#"
);
columns.Command(act => act.Custom(
"Edit"
));
columns.Bound(
"site_id"
).Title(
"Acc ID"
);
columns.Bound(
"site_name"
).Title(
"Account Name"
);
columns.Bound(
"rating_score"
).Title(
"Rating"
).HtmlAttributes(
new
{ @
class
=
"ratingCol"
});
columns.Bound(
"date_time"
).Title(
"Created"
).Format(
"{0:MM/dd/yyyy HH:mm}"
);
columns.Bound(
"comments"
).Title(
"Comment"
);
columns.Bound(
"action_taken"
).Title(
"Action"
);
})
.DataSource(dataSource => dataSource.Ajax()
.Read(read => read.Action(
"Query"
,
"KBFeedback"
).Data(
"GetSearchCriteria"
))
.Sort(sort => sort.Add(x => x.date_time))
)
.Pageable()
.Sortable(sort => sort.AllowUnsort(
false
).Enabled(
true
).SortMode(GridSortMode.SingleColumn))
)
Second question: The sort option doesn't seem to be reaching the MVC action.
public
JsonResult Query(DataSourceRequest request, KBFeedbackSearchCriteria query)
{
// Here request contains the page number and page size but the Sorts collection is null
int
count = 42;
// Get count from linq query
IEnumerable<SolutionFeedback> results =
null
;
// Get data from linq query
return
Json(
new
DataSourceResult() { Data = results, Total = count }, JsonRequestBehavior.AllowGet);
}
From another thread I found I saw a recommendation to make sure kendo.aspnetmvc.min.js is included but I checked and it is.
@Scripts.Render("~/bundles/modernizr")
<!--This bundle was moved by the Kendo UI VS Extensions for compatibility reasons-->
@Scripts.Render("~/bundles/jquery")
<!--This CSS entry was added by the Kendo UI VS Extensions for compatibility reasons-->
<
link
href
=
"@Url.Content("
~/Content/kendo.compatibility.css")"
rel
=
"stylesheet"
type
=
"text/css"
/>
<
link
href
=
"@Url.Content("
~/Content/kendo/2012.3.1315/kendo.common.min.css")"
rel
=
"stylesheet"
type
=
"text/css"
/>
<
link
href
=
"@Url.Content("
~/Content/kendo/2012.3.1315/kendo.dataviz.min.css")"
rel
=
"stylesheet"
type
=
"text/css"
/>
<
link
href
=
"@Url.Content("
~/Content/kendo/2012.3.1315/kendo.default.min.css")"
rel
=
"stylesheet"
type
=
"text/css"
/>
<
link
href
=
"@Url.Content("
~/Content/kendo/2012.3.1315/kendo.dataviz.default.min.css")"
rel
=
"stylesheet"
type
=
"text/css"
/>
<
script
src
=
"@Url.Content("
~/Scripts/kendo/2012.3.1315/jquery.min.js")"></
script
>
<
script
src
=
"@Url.Content("
~/Scripts/kendo/2012.3.1315/kendo.all.min.js")"></
script
>
<
script
src
=
"@Url.Content("
~/Scripts/kendo/2012.3.1315/kendo.aspnetmvc.min.js")"></
script
>
<
script
src
=
"@Url.Content("
~/Scripts/kendo.modernizr.custom.js")"></
script
>