편집하는 동안 행의 열에 라디오 버튼이 있어야하는 jqGrid가 있습니다. 다음 내 코드입니다 :jqGrid 사용자 정의 edittype (라디오 버튼 열) 편집시 사용자 정의 요소가 실행되지 않음
function BindPreclosingDocs(response) {
var previouslyselectedRow;
var preclosingtable = $('#preclosing');
preclosingtable.jqGrid({
datatype: 'jsonstring',
datastr: JSON.stringify(response.ServiceModel),
colNames: ['', 'Documents Received', 'Comments', 'SubDocument', 'NA'],
colModel: [
{ name: 'Documents', index: 'Documents', align: 'left', sortable: false, editable: false, width: 240 },
{ name: 'DocsReceived', index: 'DocsReceived', align: 'center', sortable: false, editable: true, edittype: 'checkbox', editoptions: { value: "True:False" }, formatter: "checkbox", width: 140 },
{ name: 'Comments', index: 'Comments', align: 'center', sortable: false, editable: true, edittype: "textarea", editoptions: { rows: "3", cols: "16" }, width: 180 },
{ name: 'SubDocument', index: 'SubDocument', editable: false, width: 1 },
{ name: 'NA', index: 'NA', editable: true, formatter: 'dynamicText', width: 150, edittype: 'custom', editoptions: { custom_element: radioelem, custom_value: radiovalue} }
],
rowNum: response.ServiceModel.PreClosing.length,
pager: '#preclosingpagerdiv',
viewrecords: true,
sortorder: "asc",
sortname: 'Documents',
jsonReader: {
root: "PreClosing",
repeatitems: false,
id: 'ConfigId'
},
shrinkToFit: false,
height: 'auto',
grouping: true,
groupingView: {
groupField: ['SubDocument'],
groupColumnShow: [false],
plusicon: 'ui-icon-circle-triangle-s',
minusicon: 'ui-icon-circle-triangle-n'
},
loadComplete: function() {
HideGroupHeaders(this);
},
onSelectRow: function (id) {
preclosingtable.jqGrid('saveRow', previouslyselectedRow, false, 'clientArray');
previouslyselectedRow = SetJQGridRowEdit(id, previouslyselectedRow, preclosingtable);
}
});
preclosingtable.setGridWidth('710');
};
//RowSelect
function SetJQGridRowEdit(id, previousid, grid) {
if (id && id !== previousid) {
grid.jqGrid('restoreRow', previousid);
grid.jqGrid('editRow', id, true);
previousid = id;
return previousid;
}
};
//Build radio button
function radioelem(value, options) {
var receivedradio = '<input type="radio" name="receivednaradio" value="R"';
var breakline = '/>Received<br>';
var naradio = '<input type="radio" name="receivednaradio" value="N"';
var endnaradio = '/>NA<br>';
if (value == 'Received') {
var radiohtml = receivedradio + ' checked="checked"' + breakline + naradio + endnaradio;
return radiohtml;
}
else if (value == 'NA') {
var radiohtml = receivedradio + breakline + naradio + ' checked="checked"' + endnaradio;
return radiohtml;
}
else {
return receivedradio + breakline + naradio + endnaradio;
}
};
function radiovalue(elem, operation, value) {
if (operation === 'get') {
return $(elem).val();
} else if (operation === 'set') {
if ($(elem).is(':checked') === false) {
$(elem).filter('[value=' + value + ']').attr('checked', true);
}
}
};
내 포맷터 나는 데
dynamicText: function (cellvalue, options, rowObject) {
if (cellvalue == 'R') {
return 'Received';
}
else if (cellvalue == 'N') {
return 'NA';
}
else {
return '';
}
}
$.extend($.fn.fmatter.dynamicText, {
unformat: function (cellValue, options, elem) {
debugger;
var text = $(elem).text();
return text === ' ' ? '' : text;
}
});
문제는 다음과 같이 내가 행을 선택하고 설정 발생하지 않는 편집 버튼을 검사 할 때 언 포맷터 코드입니다 무선 값 기능. 행이 선택되면 라디오 버튼을 생성하면서 radiovalue 함수로 전달됩니다. 라디오 버튼에 값을 설정할 수 있도록 도와주세요!
덕분에
답장을 보내 주셔서 감사합니다. 나는 여기에서 형식 편집을 사용하지 않는다. 선택한 행에서 행을 인라인으로 편집 중입니다. 내가 행을 선택하고 나면 라디오 버튼 그룹이 생깁니다. 이제 값 'N'을 가진 두 번째 라디오 버튼을 선택합니다. 다른 행을 선택하면 clientArray에 저장을 수행 할 때 이전에 편집 된 행의 열이 NA 열 값을 NA로 업데이트 할 것으로 예상됩니다. 하지만 'Received'로 업데이트됩니다. 라디오 버튼에서 옵션을 선택하지 않은 경우에도 '수신 됨'으로 업데이트됩니다. – fcmaine
@SrinivasPotluri : 환영합니다! 귀하의 질문은 "왜 사용자 정의 요소가 편집 이벤트를 설정하지 않습니다"입니다. 양식 편집시에만 해고되었다고 대답했습니다. 당신이 마지막 코멘트에서 물어 보는 것은 * 새로운 질문 *입니다. 'saveRow' 대신'restoreRow'를 호출하거나 사용법 사용자 정의 포맷터 대신 편집 모드에서 라디오 버튼을 사용하기 때문에 몇 가지 문제가 있다고 가정합니다. 문제를 이해하려면 테스트 데이터 **와 함께 새로운 질문 **을 게시하고 테스트 사례, 예상 결과 및 데모 결과를 자세히 설명하는 부분을 게시해야합니다. – Oleg
[link] (http : // jsfiddle.)에서 jsfiddle에 코드 예제를 추가했습니다.net/srinivaspotluri/xx7Jg/3 /) – fcmaine