如何在数据透视网格中指定行/列的默认排序顺序?
我的控制器有这个方法
public IActionResult PivotGrid() {IEnumerable<年代pan class="hljs-tag" style="color: #0000ff"><<年代pan class="hljs-name" style="color: #0000ff">ResponseReportPivot年代pan>>年代pan>objResponseList = _db.ResponseReportPivot;var sortedResponseList = objResponseList。OrderBy(s => s. eventyear)。ThenBy(s => s. venue);返回视图(sortedResponseList);}
当我运行pivot时,我得到了附加在pivot display .jpg中的显示。
如果我改变orderderby子句,我将得到Pivot display 2.jpg格式的显示。
我知道用户可以更改排序,但我希望列显示默认为事件年升序,行显示默认为场馆升序。
我还没见过任何地方能做到这一点。
这是主元网格代码
@*用于本地绑定*@ @using Application.Models;@using Kendo.Mvc.Extensions;@using Kendo.Mvc.UI;@ model IEnumerable<年代pan class="hljs-tag" style="color: #0000ff"><<年代pan class="hljs-name" style="color: #0000ff">ResponseReportPivot年代pan>>年代pan>@ {ViewBag。标题=“响应报告Pivot Grid”;} @Html.AntiForgeryToken ()<年代pan class="hljs-tag" style="color: #0000ff"><<年代pan class="hljs-name" style="color: #0000ff">风格年代pan>>年代pan>.k-pivot-table年代pan>.k-grid-content年代pan>道明年代pan>{<年代pan class="hljs-attribute" style="color: #a31515">text-align年代pan>:离开;}年代pan><年代pan class="hljs-name" style="color: #0000ff">风格年代pan>>年代pan><<年代pan class="hljs-name" style="color: #0000ff">div年代pan>类年代pan>=<年代pan class="hljs-string" style="color: #a31515">“k-pivotgrid-wrapper”年代pan>>年代pan>@(Html.Kendo().PivotConfigurator() .Name("configurator") .HtmlAttributes(new {@class = "hidden-on-narrow"}) .Filterable(true) .Sortable(true) .Height(570)) @(Html.Kendo().PivotGrid<年代pan class="hljs-tag" style="color: #0000ff"><<年代pan class="hljs-name" style="color: #0000ff">ResponseReportPivot年代pan>>年代pan>() . name ("pivotgrid") . configurator ("#configurator") . columnwidth (120) . filterable (true) . height (570) . sortable (true) . bindto (Model) . dataSource (dataSource => dataSource . ajax () . schema (schema => schema . cube (cube => cube . dimensions (dimensions => {dimensions. data)) . dataSource (dataSource => dataSource . ajax () . schema (schema => schema . cube (cube => cube . dimensions (dimensions => {dimensions. data))添加(model => model. venue)。标题(“场所”);维度。Add (model => model.EventYear).Caption("All Years"); }) .Measures(measures => { measures.Add("Count").Field(model => model.Venue).AggregateName("count"); }) )) .Columns(columns => { columns.Add("EventYear").Expand(true); }) .Rows(rows => rows.Add("Venue").Expand(true)) .Measures(measures => measures.Values("Count")) .Events(e => e.Error("onError")) ) )<年代pan class="hljs-tag" style="color: #0000ff"><年代pan class="hljs-name" style="color: #0000ff">div年代pan>>年代pan><<年代pan class="hljs-name" style="color: #0000ff">div年代pan>类年代pan>=<年代pan class="hljs-string" style="color: #a31515">“responsive-message”年代pan>>年代pan><年代pan class="hljs-name" style="color: #0000ff">div年代pan>>年代pan><<年代pan class="hljs-name" style="color: #0000ff">脚本年代pan>>年代pan>函数年代pan>onError年代pan>(<年代pan class="hljs-params">e年代pan>)年代pan>{警报(<年代pan class="hljs-string" style="color: #a31515">错误:“年代pan>+ kendo.stringify (e.errors [<年代pan class="hljs-number">0年代pan>)));}年代pan><年代pan class="hljs-name" style="color: #0000ff">脚本年代pan>>年代pan>