如何评价Gijgo网格中的复选框?

时间:2016-05-18 07:32:55

标签: asp.net-mvc grid

我正在尝试使用.addRow方法向Gijgo网格添加一行,该方法包含一个由复选框格式化的布尔类型字段,但我遇到了一些问题。在调用AddRow后,始终不会检查网格中的复选框。我试过不同的方式传递“true / 1 / checked”,但结果是一样的,没有选中复选框。

我错了? 非常感谢你

查看

                grid = $("#grid").grid({
                    dataSource:  datasourceiniziale,
                    dataKey: "Id",
                    uiLibrary: "bootstrap",
                    columns:
                    [
                        { field: "Id", sortable: false, hidden: true },
                        { field: "description", title: "Elemento specifico", width: "70%"},
                        { field: "requtile", title: "Per capacità prof.le", align: 'center', type:"checkbox" },
                        { width: 34, type: "icon", icon: "glyphicon-remove", tooltip: "Elimina", events: { "click": Delete } }
                    ]
                });


                function Save() {
                    grid.addRow({ 
                        'Id': grid.count() + 1, 
                        'description': $("#elementospecifico").val(), 
                        'requtile' : 'true' //I tried with true/1/checked/on
                    });
                }

1 个答案:

答案 0 :(得分:1)

您可以使用cellDataBound来执行此操作。您可以在http://gijgo.com/Grid/Events/cellDataBound

找到有关此活动的更多信息
grid = $("#grid").grid({
  dataSource:  datasourceiniziale,
  dataKey: "Id",
  uiLibrary: "bootstrap",
  columns:[
    { field: "Id", sortable: false, hidden: true },
    { field: "description", title: "Elemento specifico", width: "70%"},
    { field: "requtile", title: "Per capacità prof.le", align: 'center', type:"checkbox" },
    { width: 34, type: "icon", icon: "glyphicon-remove", tooltip: "Elimina", events: { "click": Delete } }
  ],
  cellDataBound, function (e, $wrapper, id, column, record) {
    if ('requtile' === column.field) {
      $wrapper.find('input[type="checkbox"]').prop( "checked", record.requtile);
    }
  }
});