2013-12-03 39 views
0

我的屏幕是访问控制,所以我有一个先前的记录在我的数据库(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"); 

谢谢!

回答

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"); 
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 
} 
+0

谢谢回答我拉斯,这两个例子部分解决了我的问题。我可以编辑但不保存在数据库中。 如何阻止这些企图版? – Isabela

+0

@Isabela我不明白这个问题 - 你想做什么,什么不工作?尝试更详细地解释(编辑问题)。还要添加你的数据源定义。 –

相关问题