Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/68.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何从控制器更新KendoUI Grids数据源?_C#_Jquery_Asp.net_Kendo Ui - Fatal编程技术网

C# 如何从控制器更新KendoUI Grids数据源?

C# 如何从控制器更新KendoUI Grids数据源?,c#,jquery,asp.net,kendo-ui,C#,Jquery,Asp.net,Kendo Ui,我正在尝试使用下面的代码更新网格的数据源。但我只想更新一个特定的列,不想重新加载整个网格。我们至少有100条记录显示,但加载需要几秒钟。我们有这样的逻辑,用户扫描条形码,它将更新列。现在,它加载了之后的所有内容 是否可以只更新特定列而不加载整个网格 $("#GridCreateShipment").data('kendoGrid').dataSource.read(); @(Html.Kendo().Grid<ProductionShipment>()

我正在尝试使用下面的代码更新网格的数据源。但我只想更新一个特定的列,不想重新加载整个网格。我们至少有100条记录显示,但加载需要几秒钟。我们有这样的逻辑,用户扫描条形码,它将更新列。现在,它加载了之后的所有内容

是否可以只更新特定列而不加载整个网格

$("#GridCreateShipment").data('kendoGrid').dataSource.read();


 @(Html.Kendo().Grid<ProductionShipment>()
          .Name("GridCreateShipment")
          .AutoBind(true)
          .Filterable(filter => filter.Extra(false).Operators(op => op.ForString(str => str.Clear().Contains("Contains"))))
          .Columns(columns =>
          {
         
              columns.Bound(p => p.OrderNo).Title("Order No.").Width(150).Filterable(false);
              columns.Bound(p => p.DetailNum).Title("Line No.").Groupable(false).Encoded(false).Filterable(false).Width(60);
              columns.Bound(p => p.ShipdateString).Title("Ship Date").Groupable(false).Encoded(false).Filterable(false).Width(100);
              columns.Bound(p => p.CustomerName).Title("Customer").Filterable(false).Width(150);
              columns.Bound(p => p.CustomerShipTo).Title("Customer Ship-To").Filterable(false).Width(150);
              columns.Bound(p => p.CustomerPO).Title("PO No.").Filterable(false).Width(90);
              columns.Bound(p => p.ItemId).Title("Item ID").Filterable(false).Width(200);
              columns.Bound(p => p.ItemDescription).Title("Description").Width(300).Filterable(false);
              columns.Bound(p => p.OrigQty).Title("Orig Qty").Filterable(false).Width(100);
              columns.Bound(p => p.QtyProduced).Title("Qty Produced").Filterable(false).Width(100);
              columns.Bound(p => p.QtyLoaded).Title("Qty Loaded").Filterable(false).Width(100);
              //columns.Bound(p => p.Routes).Filterable(false).Width(200);

          })
      
          .DataSource(dataSource => dataSource
              .Ajax()
              //BTG v.1.1.62 
              //Removed
              //.Sort(x=>x.Add("OrderNo").Ascending())
              .Read(read => read.Action("GridFillCreateShipment", "Production").Data("additionalData"))
              

          )

          ) 
$(“#GridCreateShipping”).data('kendoGrid').dataSource.read();
@(Html.Kendo().Grid())
.名称(“GridCreateShipping”)
.AutoBind(真)
.Filterable(filter=>filter.Extra(false).Operators(op=>op.ForString(str=>str.Clear().Contains(“Contains”))
.列(列=>
{
columns.Bound(p=>p.OrderNo).Title(“订单号”).Width(150).Filterable(false);
columns.Bound(p=>p.DetailNum).Title(“行号”).Groupable(false).Encoded(false).Filterable(false).Width(60);
columns.Bound(p=>p.ShipdateString).Title(“shipDate”).Groupable(false).Encoded(false).Filterable(false).Width(100);
columns.Bound(p=>p.CustomerName).Title(“Customer”).Filterable(false).宽度(150);
列。绑定(p=>p.CustomerShipTo)。标题(“客户发货地址”)。可过滤(false)。宽度(150);
列。绑定(p=>p.CustomerPO)。标题(“采购订单号”)。可过滤(假)。宽度(90);
columns.Bound(p=>p.ItemId).Title(“ItemId”).Filterable(false).宽度(200);
columns.Bound(p=>p.itemsdescription).Title(“Description”).Width(300).Filterable(false);
列绑定(p=>p.OrigQty).Title(“Orig Qty”).Filterable(false).宽度(100);
列。绑定(p=>p.QtyProduced)。标题(“生产数量”)。可过滤(false)。宽度(100);
列.绑定(p=>p.QtyLoaded).Title(“加载的数量”).Filterable(false).宽度(100);
//columns.Bound(p=>p.Routes).Filterable(false).Width(200);
})
.DataSource(DataSource=>DataSource
.Ajax()
//BTG v.1.1.62
//除去
//.Sort(x=>x.Add(“OrderNo”).Ascending())
.Read(Read=>Read.Action(“GridFillCreateShipment”、“Production”).Data(“additionalData”))
)
) 

尝试以下方法:

首先,您需要从控制器获取值作为对象,其次从当前网格获取数据项/行,最后使用
“dataitem.set()”
更改列的值(这也将更新网格的视图,而不会重新加载整个网格)

您可以尝试此解决方案,但我仍然建议您在每次更改时更新所有记录,如果您不想每次都重新加载整个记录(100条记录),可以限制当前网格上显示的记录(使用pageSize或分页),这将只加载该页面大小的记录

希望这能回答你的问题

var data = //controller return;
var grid = $("#GridCreateShipment").data("kendoGrid");
var dataItem = grid.dataSource.get(data.ItemId);
dataItem.set("Customer","Devina");