javascript - Kendo UI 网格读取操作参数不起作用

标签 javascript parameters kendo-ui grid

工作

.Read(read => read.Action("Evento_Read", "Eventos", new { dataInicial = new DateTime(2014, 10, 13), dataFinal = new DateTime(2015, 10, 13) })

不工作

.Read(read => read.Action("Evento_Read", "Eventos").Data("additionalParam")   

<script type="text/javascript">
function additionalParam() {

    return {
        dataInicial: new Date(2014,10,13),
        dataFinal: new Date(2015, 10, 13)
    }
}

网格代码

@(Html.Kendo().Grid<Evento>()
  .Name("eventoGrid")
  .Columns(columns =>
  {
      columns.Bound(c => c.EventoID).Visible(false);
      columns.Bound(c => c.Cliente).Width(150);
      columns.Bound(c => c.Projeto).Width(100);
      columns.Bound(c => c.Atividade).Width(200);
      columns.Bound(c => c.DataOcorrencia).Width(180);
      columns.Bound(c => c.HorasDecimal).Title("Horas").Width(100);
      columns.Template(x => { }).ClientTemplate("<a class='k-button' href='" + Url.Action("Edit", "Eventos") + "?id=#= EventoID #'" + ">Editar</a>").Width(80);
      columns.Bound(c => c.DescricaoCurta).Width(220);
  })
  .HtmlAttributes(new { style = "height:1000px;" })
  .ToolBar(toolbar =>
  {
      toolbar.Excel();
      toolbar.Pdf();
  })
  .Resizable(resize => resize.Columns(true))
  .Pageable(pager => pager
      .Input(true)
      .Numeric(true)
      .Info(true)
      .PreviousNext(true)
      .Refresh(true)
      .PageSizes(true).ButtonCount(5)
  )
  .Selectable(selectable =>
  {
      selectable.Mode(GridSelectionMode.Single);
      selectable.Type(GridSelectionType.Row);
  })
  .Sortable(sortable => { sortable.SortMode(GridSortMode.SingleColumn); })
  .Filterable()
  .Scrollable()
  .AutoBind(true)
  .Selectable(s => s.Mode(GridSelectionMode.Multiple))
  .DataSource(dataSource => dataSource
      .Ajax()
                     .Read(read => read.Action("Evento_Read", "Eventos", new { dataInicial = new DateTime(2014, 10, 13), dataFinal = new DateTime(2015, 10, 13) })
                     //.Read(read => read.Action("Evento_Read", "Eventos").Data("additionalParam")   
    ).PageSize(100)))

最佳答案

尝试将日期参数作为字符串传递。 jQuery(Kendo UI 在后台使用)不会发送 JavaScript 日期。

function additionalParam() {
    return {
        dataInicial: "2014-10-13", // new Date(2014,10,13),
        dataFinal: "2015-10-13" //new Date(2015, 10, 13)
    };
}

关于javascript - Kendo UI 网格读取操作参数不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30090458/

相关文章:

javascript - 如何在处理时在ajax中附加基于php响应的消息?

python - Python 库文档中 ... [, param] 是什么意思?

python - 如何输入参数以列表或元组的形式运行?

c# - Kendo UI TreeListDataSource Read() 仅在本地运行时有效

javascript - ionic vue 无法从 Assets 文件夹中选取图像?

javascript - 有没有办法将 JSValue 移动到新的 JSContext 中而忽略其原始上下文?

javascript - 单击时从数据属性获取更新值

具有多个通用参数的 java lambda 表达式未编译

asp.net-mvc - 带有 Enum Kendo UI 的 DropDownList

php - 网格中的内联日期选择器不持久