2013-12-03 24 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我不明白這個問題 - 你想做什麼,什麼不工作?嘗試更詳細地解釋(編輯問題)。還要添加你的數據源定義。 –

相關問題