1

再会,

我有一个包含元素的列表,基于该列表将获得网格。我需要更改该列表中元素的顺序。因此,当我更改列表的顺序并运行报告时,网格是按照前列表的顺序获取的,而不是按照新更改的顺序获取的。

这是列表:

@Html.ListBox("multiselect_to", Model.AvailableColumnsList, new { @class = "form-control bdr_rad_3", size = "8", multiple = "multiple" })

这是剑道网格代码:

@(Html.Kendo().Grid<Entrada.CustomerPortal.UI.Models.JobReport>()
.Name("JobReportGrid")
  .ToolBar(tools => tools.Pdf())
  .Pdf(pdf => pdf
  .AllPages()
  .FileName("Kendo UI Grid Export.pdf")
  .ProxyURL(Url.Action("Excel_Export_Save", "JobReports")))
  .ToolBar(tools => tools.Excel())
  .Excel(excel => excel
  .AllPages(true)
  .FileName("Kendo UI Grid Export.xlsx")
  .ProxyURL(Url.Action("Excel_Export_Save", "JobReports")))
  .ColumnMenu()
  .Columns(columns =>
  {
    columns.Bound(p => p.JobNumber)//.Title("Job <br/> Number")
        .Width(colWidth["Job Number"])
        .ClientTemplate("<a class='jobReportGridJN' jnum='#=JobNumber#'>" + "#=JobNumber#" + "</a>"+
    @" #if(STAT== true) {#  <span><img src='" + Url.Content("~/Images/stat-icon.png") + "'> </span>#}#");

    columns.Bound(p => p.DictatorID);
    columns.Bound(p => p.JobType);//.Title("Job <br/> Type");
    columns.Bound(p => p.DeviceGenerated)//.Title("Device <br/> Generated")
        .Width(colWidth["Device Generated"]);
    columns.Bound(p => p.AppointmentDate)//.Title("Appointment <br/> Date")
        .Width(colWidth["Appointment Date"])
        .Format(colFormat["Appointment Date"]);
    columns.Bound(p => p.InProcess)//.Title("In <br/> Process")
        .Width(colWidth["In Process"])
        .Format(colFormat["In Process"]);
    columns.Bound(p => p.EditingComplete)
        .Width(colWidth["Editing Complete"])
        .Format(colFormat["Editing Complete"]);
    columns.Bound(p => p.JobStatus);//.Title("Job <br/> Status");
    columns.Bound(p => p.MRN);
    columns.Bound(p => p.Patient);
  })
  .Groupable()
  .Selectable(selectable => selectable
  .Mode(GridSelectionMode.Single)
  .Type(GridSelectionType.Row))
  .DataSource(dataSource => dataSource
    .Ajax()
    .Read(read => read
        .Action("JobSearchPaginationGrid", "JobReports")
        .Data("residentsReadData"))
    .Events(events => events.Error("error_handler"))
    .PageSize((int)ViewData["PageSize"])
    .Group(group => group.Add<string>((string)TempData["GridGroupBy"]))
    .ServerOperation(true)
    )
  .Pageable(pager => pager.Messages(Info => Info.Empty("No Results Found")))
  .Sortable()
  .Resizable(resize => resize.Columns(true))
  .Scrollable().Selectable(s => s.Mode(GridSelectionMode.Single).Type(GridSelectionType.Row))
)

更改元素列表顺序之前的 Kendo UI 网格列的图像

更改顺序后的列表图像

那么,我可以在更改列表顺序后根据该列表元素重新排序 Grid 列吗?

如果有人快速回答,那将更有帮助。

谢谢,

4

1 回答 1

0

我自己没有尝试过,但是经过一分钟的谷歌搜索,如果我理解正确的话,实现这一目标的过程似乎涉及两个步骤:

  1. 首先,您必须将网格的 reorderable 设置为 true

    .Reorderable(reorder => reorder.Columns(true))

http://demos.telerik.com/aspnet-mvc/grid/column-reordering

  1. 在列表更改事件中以编程方式重新排序列:

    var grid = $("#JobReportGrid").data("kendoGrid"); grid.reorderColumn(newOrderIndex, grid.columns[currentIndex]);

http://docs.telerik.com/KENDO-UI/api/javascript/ui/grid#methods-reorderColumn

于 2015-10-06T21:04:08.220 回答