当我使用json参数调用jqgrid的值时,值正确显示但是当我编辑表值时 这些值是随机编辑的。 例如,当我编辑第1行时,则编辑5行。
以下是我的jqgrid代码:
$(document).ready(function () {
$('#form_table').jqGrid('setCell', 2, 'column Name', '', {color: 'red'});
jQuery("#form_table").jqGrid({
datatype: "json",
mtype: "POST",
url: '',
colNames: ['Id', 'सदस्यहरुको नाम थर', 'उपस्थित', 'लिङ्ग', 'जातजाती', 'उमेर ', 'ठेगाना(गाबिस,वडा नं)', 'समुह स्थापना गर्दा कृषकहरुसंग भएका कुखुराको संख्या ', 'सेवा केन्द्र', 'जिल्ला', 'क्षेत्रिय'],
colModel: [
{name: 'id', index: 'Id', jsonmap: "Id", hidden: true, },
{name: 'name', index: 'name', jsonmap: "name", width: 220, editable: false},
{name: 'present', index: 'present', jsonmap: 'present', width: 60, editable: false, edittype: 'select', editoptions: {value: {1: "छ", 0: "छैन"}}, formatter: "select"},
{name: 'gender', index: 'gender', jsonmap: "gender", width: 70, editable: false, align: "center", edittype: 'select', editoptions: {value: {<?php echo $gender_list;?>}}, formatter: "select"},
{name: 'caste', index: 'caste', jsonmap: "caste", width: 70, editable: false, align: "center", edittype: 'select', editoptions: {value: {<?php echo $caste_list;?>}, defaultValue: ' '}, formatter: "select"},
{name: 'age_group', index: 'age_group', jsonmap: "age_group", width: 80, editable: false},
{name: 'member_address', index: 'member_address', jsonmap: "member_address", editable: true, },
{name: 'krishak_sanga_bhayeka_kukhura', index: 'krishak_sanga_bhayeka_kukhura', jsonmap: "krishak_sanga_bhayeka_kukhura", width: 120, editable: true, },
{name: 'service_center', index: 'service_center', jsonmap: "service_center", editable: true, },
{name: 'training_district', index: 'training_district', jsonmap: "training_district", width: 100, editable: true, align: 'center', edittype: 'select', editoptions: {
value: {<?php
foreach ($districts as $district) {
echo "'" . $district->dis_nepali . "': '" . $district->dis_nepali . "', ";
}
?>}, defaultValue: ''}, formatter: 'select'},
{name: 'training_region', index: 'training_region', jsonmap: "training_region", width: 100, editable: true, align: "center", edittype: 'select', editoptions: {value: {'मध्य पश्चिम': "मध्य पश्चिम", 'सुदूर पश्चिम': "सुदूर पश्चिम"}}, formatter: "select"}
],
jsonreader: {repeatitems: false, id: 'id', root: 'root'},
pager: '#form_pager',
toppager: true, //for pager on top
height: "auto",
rowList: [25, 50, 75, 100],
viewrecords: true,
gridview: true,
resizable: true,
rownumbers: true,
caption: "समुहको विवरण:",
loadtext: 'Loading...',
cellEdit: true,
contentType: "application/json",
cellsubmit: 'clientArray',
cellurl: ""
});
jQuery("#form_table").jqGrid('setGroupHeaders', {
useColSpanStyle: true,
groupHeaders: [
{startColumnName: 'service_center', numberOfColumns: 3, titleText: 'कुखुरा पालन सम्बन्धी तालिम पाएको भए'}
]
});
});
答案 0 :(得分:0)
我已经用以下内容替换了jsonreader并且它有效 很抱歉给您带来不便
jsonReader:{ 细胞: ””, id:“0” },