I am restoring a Grid using loadState with the code below. This seems to work fine, it reloads the search and sort and data but I do get a:
jquery.jqGrid.min.js?1622273992:221 Uncaught TypeError: Cannot read property ‘beforeProcessing’ of undefined
at C (jquery.jqGrid.min.js?1622273992:221)
at Object.success (jquery.jqGrid.min.js?1622273992:228)
error.
The initial grid load (when there is no saved State) does not show the error.
In the localData beforeProcessing is set to null.
Is this a bug or am I doing something wrong here?
Using jqGrid 5.5.5 & jQuery 3.6.0
1 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 |
<script type="text/javascript"> $('#confirm-delete').on('show.bs.modal', function (e) { $(this).find('.btn-ok').attr('href', $(e.relatedTarget).data('href')); }); function nullFormatter(cellVal, options, rowObject) { if (cellVal === undefined || cellVal === 'null' || cellVal === 'NULL' || cellVal === null) { cellVal = '&nbsp;'; } return cellVal; } function pActionFormatter(cellVal, options, rowObject) { var upda = "{{.BaseURI}}onlinedeclaratie/upersn/" + rowObject["id"]; var dela = "{{.BaseURI}}onlinedeclaratie/dpersn/" + rowObject["id"]; var kopa = "{{.BaseURI}}onlinedeclaratie/koppelshow/" + rowObject["id"]; var patient = "{{.BaseURI}}onlinedeclaratie/decvoor/" + rowObject["id"]; return "<div class='actiondiv'>" + "<div><a href='" + patient + "' title='Declareer' rel="nofollow"><span class='glyphicon glyphicon-euro'></span></a></div>" + "<div><a href='" + upda + "' title='Bewerk' rel="nofollow"><span class='glyphicon glyphicon-pencil'></span></a></div>" + "<div><a href='#' title='Verwijder' rel="nofollow"><span class='glyphicon glyphicon-trash'></span></a></div>" + "</div>"; } $('#onlGrid').jqGrid({ caption: "Patienten", url: '{{.BaseURI}}onlinedeclaratie/pdata', mtype: "GET", styleUI: 'Bootstrap', datatype: "json", colNames: ["Id", "Naam", "Geboortedatum", "Geslacht", "Postcode", "Plaats", "Bsn", "Verzekerdennummer", "ION", "Aktie"], colModel: [ { label: "Id", name: "id", key: true, align: "left", width: 80, resizable: true, sortable: true, sorttype: "int", formatter: nullFormatter, formatoptions: null, }, { label: "Naam", name: "naam", align: "left", width: 120, resizable: true, search: true, sortable: true, sorttype: "text", searchoptions: {sopt: ["cn"]}, formatter: "", formatoptions: null, }, { label: "Geboortedatum", name: "geboortedatum", align: "left", width: 100, resizable: true, sortable: true, sorttype: "date", formatter: "date", formatoptions: {"srcformat": "Y-m-d", "newformat": "d-m-Y"}, searchoptions: { dataInit: function (e) { $(e).datepicker({autoclose: true, format: "d-m-yyyy"}); } } }, { label: "Geslacht", name: "geslacht", align: "center", width: 90, sortable: true, resizable: true, stype: "select", searchoptions: {value: ":M+V;M:M;V:V"}, formatter: "", formatoptions: null, }, { label: "Postcode", name: "postcode", align: "left", width: 100, resizable: true, sortable: true, sorttype: "text", formatter: nullFormatter, formatoptions: null, }, { label: "Plaats", name: "plaats", align: "left", width: 120, resizable: true, sortable: true, sorttype: "text", formatter: nullFormatter, searchoptions: {sopt: ["cn"]}, formatoptions: null, }, { label: "Bsn", name: "bsn", align: "left", width: 80, resizable: true, sortable: true, sorttype: "text", formatter: nullFormatter, formatoptions: null, }, { label: "Verzekerdennummer", name: "verzekerdennummer", align: "left", width: 100, resizable: true, sortable: true, sorttype: "text", formatter: nullFormatter, }, { label: "ION", name: "inschrijftarief", align: "center", width: 80, resizable: true, sortable: true, sorttype: "text", stype: "select", searchoptions: {value: ":J+N;J:J;N:N"}, formatter: "", formatoptions: null, }, { label: "Aktie", name: "myacp", fixed: true, search: false, resize: false, formatter: pActionFormatter, formatoptions: "", } ], viewrecords: true, height: 'auto', //width: '100%', rowNum: 10, rowList: ["10:10", "25:25", "50:50", "100:100", "9999999:All"], autowidth: true, shrinkToFit: true, responsive: true, loadonce: true, footerrow: true, userDataOnFooter: true, storeNavOptions: true, pager: '#onlGridPager', treeGrid: false, }); $('#onlGrid').navGrid('#onlGridPager', { edit: false, add: false, del: false, search: false, refresh: false, view: false, position: "left", cloneToTop: false, }); function excelButtonClicked() { $("#onlGrid").jqGrid('exportToExcel', { includeLabels: true, includeGroupHeader: true, includeFooter: true, fileName: "patienten.xlsx", //maxlength : 100 // maxlength for visible string data }); } $('#onlGrid').navButtonAdd('#onlGridPager', { buttonicon: "", title: 'Refresh', caption: '<i class="fas fa-sync"></i> Refresh', position: 'first', onClickButton: function (e) { console.log('refresh and reload'); $.jgrid.loadState('onlGrid', null, {restoreData: false, compression: true}); $('#onlGrid').jqGrid('setGridParam', {datatype: 'json'}).trigger('reloadGrid'); } }); $('#onlGrid').navButtonAdd('#onlGridPager', { buttonicon: "", title: "Excel", caption: '<i class="far fa-file-excel"></i> Excel', position: "last", onClickButton: excelButtonClicked }); $('#onlGrid').jqGrid('filterToolbar', { stringResult: true, searchOnEnter: true, defaultSearch: 'cn', ignoreCase: true, restoreFromFilters: true, }); $(function() { if ($.jgrid.isGridInStorage('onlGrid')) { console.log('loading state after loaded'); $.jgrid.loadState('onlGrid', null, {restoreData: true, compression: true}); } }); addEventListener('unload', (event) => { console.log('The page is unloaded save the grid'); $.jgrid.saveState('onlGrid',{saveData:true, compression: true}); }); </script> |
Copyright 2014 TriRand LtdAll Rights ReservedRSS
Back to Top