Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/csharp-4.0/2.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# 4.0 带有剑道网格的复选框列_C# 4.0_Razor_Kendo Grid_Kendo Asp.net Mvc - Fatal编程技术网

C# 4.0 带有剑道网格的复选框列

C# 4.0 带有剑道网格的复选框列,c#-4.0,razor,kendo-grid,kendo-asp.net-mvc,C# 4.0,Razor,Kendo Grid,Kendo Asp.net Mvc,我想添加一个复选框列作为网格下方的第一列。 谁能帮我加上它吗 @(Html.Kendo().Grid(Model) .Name("items") .Columns(columns => { columns.Bound(p => p.itemname).Title("Name"); columns.Bound(p => p.cost).Title("Cost"); columns.B

我想添加一个复选框列作为网格下方的第一列。 谁能帮我加上它吗

 @(Html.Kendo().Grid(Model)
      .Name("items")
      .Columns(columns =>
      {
          columns.Bound(p => p.itemname).Title("Name");
          columns.Bound(p => p.cost).Title("Cost");
          columns.Bound(p => p.stockinhand).Title("Stock in hand");
          columns.Command(command => command.Destroy()).Width(100);
      })
     .Pageable()
             .DataSource(dataSource => dataSource
                .Server() 
                .Model(model => model.Id(p=>p.Id))
                .Destroy(update => update.Action("EditingInline_Destroy", "Grid"))
            )
)
我就是这样做的:

columns.Template(@<text></text>).ClientTemplate("<input type='checkbox' #= IsAdmin ? checked='checked':'' # class='chkbx' />")

您好,您可以在标题和列中添加复选框,如下所示:

columns.Bound(p => p.Status).HeaderTemplate("<input id='selectall' class='chkbx' type='checkbox' onclick='ToggleChkBox(this.checked);' />").ClientTemplate("<input id='checkbox' onclick='grdChkBoxClick(this); ' class='chkbxq' type='checkbox' />").Sortable(false).Filterable(false).Width(30);
//Cell click Checkbox select
$('#Grid').on("click", "td", function (e) {
    var selectedTd = $(e.target).closest("td");
        var grdChkBox = selectedTd.parents('tr').find("td:first").next("td").find('input:checkbox');
        grdChkBox.prop('checked', !grdChkBox.prop('checked'));

});
并选中所有复选框功能,如下所示:

function ToggleChkBox(flag) {
    $('.chkbxq').each(function () {
        $(this).attr('checked', flag);
    });
}

我通常在模型中添加一个布尔列;像下面这样

@(Html.Kendo().Grid(Model)
  .Name("items")
  .Columns(columns =>
  {
      columns.Bound(p => p.status).ClientTemplate("<input type='checkbox' disabled #= status == true ? checked='checked' : '' # />");
      columns.Bound(p => p.itemname).Title("Name");
      columns.Bound(p => p.cost).Title("Cost");
      columns.Bound(p => p.stockinhand).Title("Stock in hand");
      columns.Command(command => command.Destroy()).Width(100);
  })
 .Pageable()
         .DataSource(dataSource => dataSource
            .Server() 
            .Model(model => model.Id(p=>p.Id))
            .Destroy(update => update.Action("EditingInline_Destroy", "Grid"))
        )
)
@(Html.Kendo().Grid(模型)
.名称(“项目”)
.列(列=>
{
columns.Bound(p=>p.status).ClientTemplate(“”);
columns.Bound(p=>p.itemname).Title(“Name”);
columns.Bound(p=>p.cost).Title(“cost”);
columns.Bound(p=>p.stockinhand).Title(“库存”);
Command(Command=>Command.Destroy()).Width(100);
})
.Pageable()
.DataSource(DataSource=>DataSource
.Server()
.Model(Model=>Model.Id(p=>p.Id))
.Destroy(update=>update.Action(“editingline\u Destroy”,“Grid”))
)
)

要禁用它,直到按下“编辑”按钮,只需在ClientTemplate中添加“disabled”。应该这样做。谢谢。

您可以使用此选项在每行标题中添加复选框

@(Html.Kendo().Grid<Kendo.Mvc.Examples.Models.ProductViewModel>()
.Name("Grid")
.Columns(columns => {
    columns.Select();
    columns.Bound(p => p.ProductName);
    columns.Bound(p => p.UnitPrice);
    columns.Bound(p => p.UnitsInStock);
    columns.Bound(p => p.Discontinued);
})
.Pageable()
.Sortable()
.Events(ev=>ev.Change("onChange"))
.PersistSelection()
.DataSource(dataSource => dataSource
    .Ajax()
    .Model(model => model.Id(p => p.ProductID))
    .Read(read => read.Action("Selection_Read", "Grid"))
))
@(Html.Kendo().Grid())
.名称(“网格”)
.列(列=>{
columns.Select();
columns.Bound(p=>p.ProductName);
columns.Bound(p=>p.UnitPrice);
columns.Bound(p=>p.UnitsInStock);
columns.Bound(p=>p.contracted);
})
.Pageable()
.Sortable()
.Events(ev=>ev.Change(“onChange”))
.持续性选择()
.DataSource(DataSource=>DataSource
.Ajax()
.Model(Model=>Model.Id(p=>p.ProductID))
.Read(Read=>Read.Action(“Selection\u Read”,“Grid”))
))
在这里,我们使用PersistSelection()在所有页面上持久化所选项目


如果column.Select()给出错误或未绑定网格,则升级剑道UI版本。它可以工作。

使用带内联编辑模式的网格,如何禁用此复选框,直到该行进入编辑模式?如何添加数据标签?我尝试了==>columns.Template(@).ClientTemplate(“”)
@(Html.Kendo().Grid<Kendo.Mvc.Examples.Models.ProductViewModel>()
.Name("Grid")
.Columns(columns => {
    columns.Select();
    columns.Bound(p => p.ProductName);
    columns.Bound(p => p.UnitPrice);
    columns.Bound(p => p.UnitsInStock);
    columns.Bound(p => p.Discontinued);
})
.Pageable()
.Sortable()
.Events(ev=>ev.Change("onChange"))
.PersistSelection()
.DataSource(dataSource => dataSource
    .Ajax()
    .Model(model => model.Id(p => p.ProductID))
    .Read(read => read.Action("Selection_Read", "Grid"))
))