猿问

设置并使用localStorage在表单编辑期间保留复选框选择

我有一个表单,jqGrid用于表单的一部分。本部分显示可以通过复选框选择的用户信息。在审阅页面上,有一个用于编辑表单的选项,在此过程中,我试图保留复选框的选择。


我正在尝试为此使用window.localStorage,但是我不确定如何正确设置setItem。我在loadComplete中调用getItem,在这里我的编码也可能不太正确。我现在所拥有的,当用户去编辑时,在jqGrid中选择第一个项目,而不是实际保存的项目。我猜是因为我没有正确设置setItem。谁能提供指导?


$.jgrid.gridUnload("#list");


myGrid = $("#list").jqGrid({

    url: baseURL + '/scripts/get_user_list.php' + urlString,

    datatype: "json",

    mtype: 'POST',

    width: 660,

    height: '100%',

    pager: '#pager',

    rowNum: 10,

    rowList: [20, 30, 40, 50, 60],

    sortname: 'id',

    sortorder: "asc",

    viewrecords: true,

    multiselect: true,

    repeatitems: false,

    imgpath: '/scripts/jquery-ui/images',


    colNames: ['id', 'Building', 'Company ID', 'Description', 'Individual Name', 'SECCode'],

    colModel: [

        {name: 'id', index: 'id', jsonmap: 'id', hidden: true, width: 20},

        {name: 'Building', index: 'Building', jsonmap: 'Building', hidden: true, width: 20},

        {name: 'CompanyId', index: 'CompanyId', jsonmap: 'CompanyId', width: 110},

        {name: 'Description', index: 'Description', jsonmap: 'Description', sortable: true, width: 300},

        {name: 'IndName', index: 'IndName', jsonmap: 'IndName', width: 200},

        {name: 'UsrNum', hidden: true, index: 'UsrNum', jsonmap: 'UsrNum'}

    ],

    jsonReader: {

        repeatitems: false,

        root: 'rows',

        id: '0',

        cell: '',

        subgrid: {

            root: 'rows',

            id: '0',

            cell: '',

            repeatitems: false

        }

    },


    // subgrid support

    subGrid: true,

    subGridUrl: baseURL + '/scripts/get_user_list.php' + urlString,

    subGridModel: [{

        name: ['Date', 'ID'],

        params: ['CompanyId'],

        align: ['center', 'right'],

        width: [150, 80]

    }

    ],


    ondblClickRow: function (id) {

        $('#recId').val(id);

    },




大话西游666
浏览 206回答 1
1回答
随时随地看视频慕课网APP

相关分类

JavaScript
我要回答