davistom
|
|
« Reply #4 on: May 27, 2017, 09:31:56 AM » |
|
At the end of this post, I have included a code snippet representing a jeasyui datagrid configuration. The webpage in which the snippet is incorporated accesses a MySql database table via php. The snippet is functionally complete except for the required head element style sheet/javascript links and the php server script which extracts/returns data from the database. The database table includes 4342 data records and all initialization, sorting and scrolling behavior is exactly as expected when no row selection is involved. When a row selection is made anywhere in the 4342 record data set and the resulting selection is examined, e.g. by observing $(this).datagrid(''getSelected') via Chrome Developer Tools, the correct data record is presented. However, if the selected record exists in a page deep within the data set, any scrolling or sorting event which requires a new data request to the server results in loss of the row selection, with the previous $(this).datagrid(''getSelected') row data presentation replaced by the string "id". In that case, the configured onLoadSuccess alert is triggered.
<div> <table id="burials-list-datagrid" style="width: 100%; height: 222px;"> <thead> <tr> <th field="id" data-options="hidden: true">id</th> <th field="cid" data-options="hidden: true">cid</th> <th field="decedent" style="width: 35%;" data-options="sortable: true">Decedent</th> <th field="dob" style="width: 10%;">Date of Birth</th> <th field="dod" style="width: 10%;">Date of Death</th> <th field="cemetery" style="width: 35%;" data-options="sortable: true">Cemetery</th> <th field="collection" style="width: 10%;" data-options="sortable: true">Collection</th> </tr> </thead> </table> </div> <script> $(document).ready(function(){ $('#burials-list-datagrid').datagrid({ idField: 'id', multiSort: true, onLoadSuccess: function(data){ var s = $(this).datagrid('getSelected'); if(s == 'id') alert(s); }, pageSize: 50, queryParams: {ajax: true}, rownumbers: true, singleSelect: true, sortName: 'decedent', sortOrder: 'asc', striped: true, url: '<?php echo NHGW_URL, 'test.php';?>', view: scrollview }); }); </script>
|