Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/70.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
在kendo grid mulitiple复选框中,选中在mvc4中jquery读取时仅获取一个值_Jquery_Kendo Grid - Fatal编程技术网

在kendo grid mulitiple复选框中,选中在mvc4中jquery读取时仅获取一个值

在kendo grid mulitiple复选框中,选中在mvc4中jquery读取时仅获取一个值,jquery,kendo-grid,Jquery,Kendo Grid,这是我的剑道格网 @(Html.Kendo().Grid(Model) .Name("grid1") .Columns(columns => { columns.Bound(p => p.Associate).ClientTemplate("<input id='assetcheck' name='assetcheck' type='checkbox' #= Associate == 'true' ? checked='checked':'' # c

这是我的剑道格网

 @(Html.Kendo().Grid(Model)
  .Name("grid1")
  .Columns(columns =>
  {
      columns.Bound(p => p.Associate).ClientTemplate("<input id='assetcheck' name='assetcheck' type='checkbox'  #= Associate == 'true' ? checked='checked':'' # class='chkbx'/>").Width(35).HeaderTemplate("<input id='checkall' type='checkbox' onclick='checkAll(this)'>").Filterable(false).Sortable(false); 
      // columns.Bound(p => p.IsAttached).ClientTemplate("<input type='checkbox' #= IsAttached == 'true' ? checked='checked' : '' #  onclick='attachedchanged(this);'  />");
      columns.Bound(p => p.AssetNumber).Title("Asset Number");// #= AssetId @<text></text>  ':'' #  onclick='attachedchanged(this);  == 'true'
      columns.Bound(p => p.AssetName);
      columns.Bound(p=>p.ParentAsset);
      columns.Bound(p => p.ParentCompany).Title("Company");
      columns.Bound(p => p.AssetId).Hidden();
  })
 //  .Pageable()
  .Sortable()
  .Scrollable(scr => scr.Height(400))
  .Filterable()
  .Selectable(s => s.Mode(GridSelectionMode.Multiple))
 // .Events(events => events.Change("Grid_OnRowSelectUID"))
//.Pageable(pageable => pageable
       // .Refresh(true)
       // .PageSizes(true)
      //  .ButtonCount(5))
         .DataSource
          (
          dataSource => dataSource
              .Ajax()
             // .PageSize(10)
              .ServerOperation(false)
              .Read(read => read.Action("GetAssociateAssetParent", "Asset").Data("getMsgType"))
                 //  .Model(model => model.Id(p => p.AssetId))
           )
    )
}

在网格中,我选择了两个复选框,但这里我得到了第二个值…第一个值我没有得到使用的书籍

  // getting kendo grid 
  var grid = $("#grid1").data("kendoGrid");

  // list of selected and unselected books
  var books = [];

  // getting all the checked rows
  grid.tbody.find("input:checked").closest("tr").each(function (index) {
    grid.select($(this));
    var dataItem = grid.dataItem($(this));
    dataItem.assetcheck = 'true';
    books.push(dataItem);
  });

  // getting all the unchecked rows
  grid.tbody.find("input:not(:checked)").closest("tr").each(function (index) {
    grid.select($(this));
    var dataItem = grid.dataItem($(this));
    dataItem.assetcheck  = 'false';
    books.push(dataItem);
  });
最后在ajax调用中发送整个数据并保存

  // getting kendo grid 
  var grid = $("#grid1").data("kendoGrid");

  // list of selected and unselected books
  var books = [];

  // getting all the checked rows
  grid.tbody.find("input:checked").closest("tr").each(function (index) {
    grid.select($(this));
    var dataItem = grid.dataItem($(this));
    dataItem.assetcheck = 'true';
    books.push(dataItem);
  });

  // getting all the unchecked rows
  grid.tbody.find("input:not(:checked)").closest("tr").each(function (index) {
    grid.select($(this));
    var dataItem = grid.dataItem($(this));
    dataItem.assetcheck  = 'false';
    books.push(dataItem);
  });