简体   繁体   English

使用jQuery更改Kendo Grid DataSource特定字段

[英]Change Kendo Grid DataSource specific field with jQuery

I'm new to Kendo UI and would appreciate your advice. 我是Kendo UI的新手,非常感谢您的建议。

I have a Partial view that renders Kendo Grid: 我有一个渲染Kendo Grid的局部视图:

<div class="accountsWindow" hidden="hidden">    
    @Html.Partial("AccountsGrid", context.CustomerAccounts)    
</div>

The view: AccountsGrid.cshtml 视图: AccountsGrid.cshtml

@model IEnumerable<DAL.Model.CustomerAccount>

<div id="grid">
    @(Html.Kendo().Grid(Model)
      .Name("AccountsGrid")
      .Columns(columns =>
      {
          columns.Bound(u => u.CUSTOMER_NO)
          ...    
      })
     .Pageable().HtmlAttributes(new {id="AccGrid" })
    )
</div>

My first problem is when I try to access the grid: 我的第一个问题是当我尝试访问网格时:

var grid = $("#AccGrid").data("kendoGrid");

It is undefined . 它是undefined Can it be because of hidden Partial? 可能是因为部分隐藏了吗?

And second- I would like to change existing dataSource for context.CustomerAccounts.Where(c=>c.CUSTOMER_NO == someValue) dynamically but cannot find a solution. 第二-我想动态更改context.CustomerAccounts.Where(c=>c.CUSTOMER_NO == someValue)现有数据源,但是找不到解决方案。

And you can use json + jQuery for the change your data source 您可以使用json + jQuery更改数据源

var grid = $("#AccountsGrid").data("kendoGrid");
grid.setDataSource(dataSource);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM