當我在內聯編輯期間更改特定列的值時,我想要動態更改同一行另一列的可編輯屬性值。下面是我的代碼的一部分:jqgrid內嵌編輯:動態設置可正確編輯另一列的列
{ name: "admin", width:250, editable:<?php echo $owner; ?>, edittype:"custom", editoptions: {
custom_element: myelem,
custom_value:myvalue,
dataEvents: [{
type: 'change',
fn: function (e) {
var $this = $(e.target), $td, rowid;
var radSel = $(e.target).val(); //alert(radSel);
if(radSel == "No"){
if ($this.hasClass("FormElement")) {
$("#request").prop("editable", true);
} else {
//alert("you are here!!");
var row = $this.closest('tr.jqgrow');
var rowId = row.attr('id'); //alert(rowId);
$("#" + rowId + '_request').prop("editable", true);
}
}
}
}]
}},
{ name: "request", width: 100},
......
function myelem (value, options) {
var radio1 = document.createElement('input');
radio1.id = 'radY';
radio1.type = 'radio';
radio1.name = 'appr';
radio1.value = 'Yes';
if(value.match(/^Yes.*/)){ radio1.checked = true; }
var radio2 = document.createElement('input');
radio2.id = 'radN';
radio2.type = 'radio';
radio2.name = 'appr';
radio2.value = 'No';
if(value.match(/^No.*/)){ radio2.checked = true; }
var label1 = document.createElement('label');
label1.setAttribute('for', radio1.id);
label1.innerHTML = 'Yes';
var label2 = document.createElement('label');
label2.setAttribute('for', radio2.id);
label2.innerHTML = 'No';
var container = document.createElement('div');
container.appendChild(radio1);
container.appendChild(label1);
container.appendChild(radio2);
container.appendChild(label2);
return container;
}
function myvalue(elem, operation, value) {
if(document.getElementById('radY').checked) {return "Yes";}
else if(document.getElementById('radN').checked) {return "No";}
else {return ""; }
}
當我改變的單選按鈕「否」,它確實進入,如果循環(下dataEvents),但可編輯的屬性上的「請求」列沒有動態設置爲true。任何幫助非常感謝。謝謝。
'editable'屬性將在開始編輯之前由jqGrid *使用。 **如果要防止動態編輯,必須在相應的現有編輯字段上設置「disable」或「reabonly」屬性/屬性**,而不是設置「editable」屬性。此外,您似乎爲自定義編輯字段分配了固定'id'屬性(''radN'',''radY'')。這很危險,因爲你可以有重複的id。內聯編輯允許您同時將多行編輯爲一行。在這種情況下,將創建兩個具有相同ID的自定義編輯元素,您將遇到問題。 – Oleg 2014-09-23 10:07:34
此外,我建議您在**'
非常感謝@ Oleg ..真的有幫助。你太棒了! – MattO 2014-09-24 11:10:02