jquery - Jqgrid表格编辑出错

标签 jquery json jquery-plugins jqgrid jqgrid-php

当我使用 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: 'कुखुरा पालन सम्बन्धी तालिम पाएको भए'}
        ]
    });



});

最佳答案

我已经用以下内容替换了 jsonreader 并且它可以工作 给您带来的不便敬请谅解

jsonReader:{ 细胞: ””, 编号:“0” },

关于jquery - Jqgrid表格编辑出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32644531/

相关文章:

javascript - 需要帮助使用简单的数据网格让多个表在单个页面上工作

jquery - 背景大小的封面风格与 Bootstrap

python - 如何通读 CSV 然后在 Python 中发布批量 API 调用

ruby-on-rails - Jbuilder Partials Merge 而不是 Nest

html - Firefox 4 必需的输入表单红色边框/轮廓

jquery - 如何使用 jQuery 将页面向上或向下滚动到 anchor ?

jQuery 调度事件?如何

asp.net - 使用 jquery 错误中的参数调用 asp.net webmethod

javascript - 如何在 2 列中显示多个 html 表格

javascript - 如何在 JavaScript 中转换文档数组中的字典?