我有一個表單,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); },
設置并使用localStorage在表單編輯期間保留復選框選擇
大話西游666
2021-05-12 14:19:15