将jqGrid数据添加回json

时间:2014-01-15 09:24:33

标签: jqgrid

使用jqGrid的内联编辑:

我在变量' jsonDataStr'中有json数据。使用jqGrid显示数据。

 $("#myGrid").jqGrid({
            colModel: [
                { name: 'authenticate', width: "80" ,align: 'center',formatter: 'checkbox',editable:true,edittype:"checkbox", editoptions:{value: "Yes:No"}, formoptions:{ rowpos:1, label: "Authenticate ", elmprefix:"(*)"},editrules:{required:true} },
                { name: 'authorize', width: "80" ,align: 'center',formatter: 'checkbox',editable:true,edittype:"checkbox", editoptions:{value: "Yes:No"}, formoptions:{ rowpos:1, label: "Authorize ", elmprefix:"(*)"},editrules:{required:true}},
            ],
            pager: '#pagerTable',
            colNames:[ 'authenticate','authorize'],
            datatype: "jsonstring",
            datastr: jsonDataStr,
            jsonReader: { repeatitems: false },
            viewrecords: true,pginput : false, forceFit :true,
            height: 83,caption :"Permissions",
            ignoreCase: true,scrollBar : false
        });


        $("#myGrid").navGrid("#pagerTable",{edit:false,add:false,del:false,search:false,refresh:false});
        $("#myGrid").inlineNav("#pagerTable");

正确显示。

现在当我保存行时,我想将数据保存到相同的json变量,' jsonDataStr'。此外,我想将信息添加到json行,

例如添加,修改或删除。有没有简单的方法呢?

有人可以帮忙吗?

1 个答案:

答案 0 :(得分:0)

也许这会有所帮助

var jsonDataStr = "some Data you need";
$("#YourGrid").jqGrid('setGridParam', { jsonDataStr: jsonDataStr }); 
$('#YourGrid').trigger('reloadGrid');
相关问题