簡體   English   中英

javascript> Kendo網格>動態列過濾不起作用

[英]javascript > Kendo grid > Dynamic column filtering not working

我正在使用劍道網格來顯示來自viewModel的信息。 視圖模型包含:

[DisplayName("Received Date")]
[DataType(DataType.Date)]
[DisplayFormat(DataFormatString = "{0:yyyy-MM-dd}", ApplyFormatInEditMode = true)]
public DateTime? ReceivedDate { get; set; }

[DisplayName("Received Month")]
public string ReceivedMonth { get { return (this.ReceivedDate == null ? "" : this.ReceivedDate.Value.ToString("MMMM")); } }

我將劍道網格設置如下:

@(Html.Kendo().Grid<ViewModel>()
      .Name("Grid")
      .HtmlAttributes(new { style = "height:100%; width:100%;" })
      .Events(events => events.DataBound("onGridDataBound").Change("onSelectionChange").Save("onGridSave"))
      .Scrollable()
      .Columns(columns =>
      {                                                               
          columns.Bound(u => u.ReceivedDate).Format("{0:dd/MM/yyyy}").Filterable(c => c.Cell(y => y.Template("datePicker"))).Width("200px");
          columns.Bound(u => u.ReceivedMonth)
           .Title("Received Date<br/>Month")

      })
      .NoRecords("No Records to Display")
      .Editable(editable => editable.Mode(GridEditMode.InLine))
      .AutoBind(true)
      .Pageable(pageable => pageable.Refresh(true).PageSizes(new[] { 10, 20, 50, 100, 200 }).ButtonCount(5))
      .Sortable()
      .Filterable(ftb => ftb.Mode(GridFilterMode.Row))
      .Reorderable(r => r.Columns(true))
      .Navigatable()
      .ColumnMenu()
      .EnableCustomBinding(true)
      .DataSource(dataSource => dataSource
          .Ajax()
          .ServerOperation(true)
          .PageSize(10)
          .Model(m =>
          {
              m.Id(i => i.Id);
          })
          .Read(read => read
              .Action("getData", "Data"))
          .Update(update => update
              .Action("updateViaGrid", "Data"))       
          )
      )
)

但是我無法使該過濾在ReceivedMonth上起作用,因為該列在下划線數據源中不存在。

我正確地解決了這個問題? 我有一個日期列,我想在它旁邊有一個只包含月份的列,我可以在其中選擇一個月份,它將返回該月份的任何數據。

非常感謝

為了快速獲勝,請嘗試.ServerOperation(false) 當前,您正在隱式地將過濾器表達式傳遞給Kendo綁定器以查找不存在的屬性。

這將在客戶端而不是服務器上執行所有分頁,排序,篩選和分組操作。

如果這不適合您的用例,則需要在Model類中實現ReceivedMonth屬性,然后可以過濾服務器端。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM