阻止版本的版本

时间:2013-12-03 19:45:46

标签: gridview grid kendo-ui blocking

我的屏幕是访问控制,因此我在我的数据库(SQL Server)中有一个访问时间的先前记录,这些时间称为步骤。

在此屏幕中我遇到问题,有一个表单可以注册班次(允许天数登录系统)。

在这种形式中,我有字段:在设置之后,我在哪里设置名称,描述和步骤,然后单击将数据发送到网格端的添加按钮。

在此网格中,我添加了步骤的名称,星期几和要删除的按钮。

我的问题是这个,我的复选框应该是可编辑的,但我的步骤名称不是。

关注我网格的códiogo:

$("#myGrid").kendoGrid({
columns: [
     { field: "Etapa", title: dialetos.lblEtapa, attributes: { style: "text-align: left" }, width: 130, visible: true },
     { field: "Domingo", title: dialetos.lblDomingo, template: "<input id='checkbox' #= Domingo ? checked='checked' : '' # type='checkbox' class='checkbox' ' />", attributes: { style: "text-align: left" }, width: 85 },
     { field: "Segunda", title: dialetos.lblSegunda, template: "<input id='checkbox' #= Segunda ? checked='checked' : '' # type='checkbox' class='checkbox' ' />", attributes: { style: "text-align: left" }, width: 80 },
     { field: "Terca", title: dialetos.lblTerca, template: "<input id='checkbox' #= Terca ? checked='checked' : '' # type='checkbox' class='checkbox' ' />", attributes: { style: "text-align: left" }, width: 75 },
     { field: "Quarta", title: dialetos.lblQuarta, template: "<input id='checkbox' #= Quarta ? checked='checked' : '' # type='checkbox' class='checkbox' ' />", attributes: { style: "text-align: left" }, width: 80 },
     { field: "Quinta", title: dialetos.lblQuinta, template: "<input id='checkbox' #= Quinta ? checked='checked' : '' # type='checkbox' class='checkbox' ' />", attributes: { style: "text-align: left" }, width: 80 },
     { field: "Sexta", title: dialetos.lblSexta, template: "<input id='checkbox' #= Sexta ? checked='checked' : '' # type='checkbox' class='checkbox' ' />", attributes: { style: "text-align: left" }, width: 75 },
     { field: "Sabado", title: dialetos.lblSabado, template: "<input id='checkbox' #= Sabado ? checked='checked' : '' # type='checkbox' class='checkbox' ' />", attributes: { style: "text-align: left" }, width: 80 },
     { title: "Remover", template: "<span class='k-button' id='btnRemover' onClick='RemoveRowSelecionada()' >Remover</span> ", attributes: { style: "text-align: left" }, width: 85 }
],
groupable: false,
sortable: true,
editable: true,
filterable: true,
pageable: true,
selectable: "row",
height: 180,
dataSource: vmObjeto.dias,
batch: true,        
change: function (e) {

    },
  }).data("kendoGrid");

谢谢!

2 个答案:

答案 0 :(得分:1)

您可以use the schema model for the grid's data source

schema: {
    model: {
        id: "ProductID",
        fields: {
            ProductID: {
                //this field will not be editable (default value is true)
                editable: false
            },
            ...
        }
    }
}

或者您可以将网格列中的field's editor设置为不可编辑的元素,例如像这样(在这种情况下,模型列是可编辑的,但用户无法手动编辑它):

{
    field: "Etapa",
    editor: function(container, options) { container.text(options.field) }
    title: dialetos.lblEtapa,
    attributes: {
        style: "text-align: left"
    },
    width: 130,
    visible: true
}

答案 1 :(得分:0)

对我有用的答案:

$(function () {
  $('#myGrid').on('click', '#chkDomingo', (function () {
  var checked = $(this).is(':checked');
  var grid = $('#myGrid').data().kendoGrid;
  var dataItem = grid.dataItem($(this).closest('tr'));
  dataItem.set('Domingo', checked);
}));

$('#myGrid').on('click', '#chkSegunda', (function () {
  var checked = $(this).is(':checked');
  var grid = $('#myGrid').data().kendoGrid;
  var dataItem = grid.dataItem($(this).closest('tr'));
  dataItem.set('Segunda', checked);
 }));

$('#myGrid').on('click', '#chkTerca', (function () {
var checked = $(this).is(':checked');
var grid = $('#myGrid').data().kendoGrid;
var dataItem = grid.dataItem($(this).closest('tr'));
dataItem.set('Terca', checked);
}));

$('#myGrid').on('click', '#chkQuarta', (function () {
var checked = $(this).is(':checked');
var grid = $('#myGrid').data().kendoGrid;
var dataItem = grid.dataItem($(this).closest('tr'));
dataItem.set('Quarta', checked);
}));

$('#myGrid').on('click', '#chkQuinta', (function () {
var checked = $(this).is(':checked');
var grid = $('#myGrid').data().kendoGrid;
var dataItem = grid.dataItem($(this).closest('tr'));
dataItem.set('Quinta', checked);
}));

$('#myGrid').on('click', '#chkSexta', (function () {
var checked = $(this).is(':checked');
var grid = $('#myGrid').data().kendoGrid;
var dataItem = grid.dataItem($(this).closest('tr'));
dataItem.set('Sexta', checked);
}));

$('#myGrid').on('click', '#chkSabado', (function () {
var checked = $(this).is(':checked');
var grid = $('#myGrid').data().kendoGrid;
var dataItem = grid.dataItem($(this).closest('tr'));
dataItem.set('Sabado', checked);
}));
});

$("#myGrid").kendoGrid({
columns: [
 { field: "Etapa", title: dialetos.lblEtapa, attributes: { style: "text-align: left" },      width: 130, visible: true },
 { field: "Domingo", title: dialetos.lblDomingo, template: "<input id='checkbox' #= Domingo ? checked='checked' : '' # type='checkbox' class='checkbox' ' />", attributes: { style: "text-align: left" }, width: 85 },
 { field: "Segunda", title: dialetos.lblSegunda, template: "<input id='checkbox' #= Segunda ? checked='checked' : '' # type='checkbox' class='checkbox' ' />", attributes: { style: "text-align: left" }, width: 80 },
 { field: "Terca", title: dialetos.lblTerca, template: "<input id='checkbox' #= Terca ? checked='checked' : '' # type='checkbox' class='checkbox' ' />", attributes: { style: "text-align: left" }, width: 75 },
 { field: "Quarta", title: dialetos.lblQuarta, template: "<input id='checkbox' #= Quarta ? checked='checked' : '' # type='checkbox' class='checkbox' ' />", attributes: { style: "text-align: left" }, width: 80 },
 { field: "Quinta", title: dialetos.lblQuinta, template: "<input id='checkbox' #= Quinta ? checked='checked' : '' # type='checkbox' class='checkbox' ' />", attributes: { style: "text-align: left" }, width: 80 },
 { field: "Sexta", title: dialetos.lblSexta, template: "<input id='checkbox' #= Sexta ? checked='checked' : '' # type='checkbox' class='checkbox' ' />", attributes: { style: "text-align: left" }, width: 75 },
 { field: "Sabado", title: dialetos.lblSabado, template: "<input id='checkbox' #= Sabado ? checked='checked' : '' # type='checkbox' class='checkbox' ' />", attributes: { style: "text-align: left" }, width: 80 },
 { title: "Remover", template: "<span class='k-button' id='btnRemover' onClick='RemoveRowSelecionada()' >Remover</span> ", attributes: { style: "text-align: left" }, width: 85 }
],
 groupable: false,
 sortable: true,
 editable: true,
 filterable: true,
 pageable: true,
 selectable: "row",
 height: 180,
 dataSource: vmObjeto.dias,
 batch: true,        
 change: function (e) {},
  }).data("kendoGrid");