Guest lorathon Posted October 21, 2010 Report Share Posted October 21, 2010 I looked for the original thread for this but could not find it. This fixes the problem where if you attempt to sort the status of pilots by Active/Inactive the entire list of pilots would disappear. To fix you need to make a modification to one file. /admin/templates/pilots_list.tpl Replace the code in the template with this. (Be sure to make a back-up of the original first.) <h3>Pilots List</h3> <table id="grid"></table> <div id="pager"></div> <br /> <link rel="stylesheet" type="text/css" media="screen" href="<?php echo fileurl('/lib/js/jqgrid/css/ui.jqgrid.css');?>" /> <script src="<?php echo fileurl('/lib/js/jqgrid/js/i18n/grid.locale-en.js');?>" type="text/javascript"></script> <script src="<?php echo fileurl('/lib/js/jqgrid/js/jquery.jqGrid.min.js');?>" type="text/javascript"></script> <script type="text/javascript"> $("#grid").jqGrid({ url: '<?php echo adminaction('/pilotadmin/getpilotsjson');?>', datatype: 'json', mtype: 'GET', colNames: ['', 'First', 'Last', 'Email', 'Location', 'Status', 'Rank', 'Flights', 'Hours', 'IP', 'Edit'], colModel : [ {index: 'id', name: 'id', hidden: true, search: false }, {index: 'firstname', name : 'firstname',sortable : true, align: 'left', search: 'true', searchoptions:{sopt:['in']}}, {index: 'lastname', name : 'lastname', sortable : true, align: 'left', searchoptions:{sopt:['in']}}, {index: 'email', name : 'email', sortable : true, align: 'left',searchoptions:{sopt:['li']}}, {index: 'location', name : 'location', sortable : true, align: 'center',searchoptions:{sopt:['eq','ne']}}, {index: 'retired', name : 'status', sortable : true, align: 'center',searchoptions:{sopt:['in']}}, {index: 'rank', name : 'rank', sortable : true, align: 'center', searchoptions:{sopt:['eq','ne']}}, {index: 'totalflights', name : 'totalflights', sortable : true, align: 'center',searchoptions:{sopt:['lt','gt']}}, {index: 'totalhours', name : 'totalhours', sortable : true, align: 'center',searchoptions:{sopt:['lt','gt']}}, {index: 'lastip', name : 'lastip', sortable : true, align: 'center', searchoptions:{sopt:['in']}}, {index: '', name : '', sortable : true, align: 'center', search: false} ], pager: '#pager', rowNum: 25, sortname: 'pilotid', sortorder: 'asc', viewrecords: true, autowidth: true, height: '100%' }); jQuery("#grid").jqGrid('navGrid','#pager', {edit:false,add:false,del:false,search:true,refresh:true}, {}, // edit {}, // add {}, //del {multipleSearch:true} // search options ); </script> Quote Link to comment Share on other sites More sharing options...
Moderators mark1million Posted October 22, 2010 Moderators Report Share Posted October 22, 2010 Thanks Jeff, nice one. [edit] Doesn't seem to work, all its done is shifted the country flag over and lost a column. Quote Link to comment Share on other sites More sharing options...
Guest lorathon Posted October 22, 2010 Report Share Posted October 22, 2010 I have modified so many thing perhaps I forgot to include something. I will do a fresh install and then repair the table. Look back for the fix in awhile. Sorry about this but I have fixed it Quote Link to comment Share on other sites More sharing options...
Guest lorathon Posted October 22, 2010 Report Share Posted October 22, 2010 I changed the original template code. I left in the pilotid column that I added for our table. I just checked this on a clean site (full install - NOT beta) and it worked fine. This is what is changed and what is happening. Line 23 of the template - ORIGINAL {index: 'status', name : 'status', sortable : true, align: 'center',searchoptions:{sopt:['in']}}, Line 23 of the template - MODIFIED {index: 'retired', name : 'status', sortable : true, align: 'center',searchoptions:{sopt:['in']}}, This changes the way it is sorted from trying to sort by the strings (Active / Retired) to indexing and sorting by the actual data in the retired column (0 = active / 1 = retired) Quote Link to comment Share on other sites More sharing options...
Moderators mark1million Posted October 22, 2010 Moderators Report Share Posted October 22, 2010 Ah im on a beta and the pilot id's are no longer displayed, that could be the problem but ill manually update that to reflect the correct column and see what happens. Quote Link to comment Share on other sites More sharing options...
Moderators mark1million Posted October 22, 2010 Moderators Report Share Posted October 22, 2010 OK so if your on a beta here is the code for you <h3>Pilots List</h3> <table id="grid"></table> <div id="pager"></div> <br /> <link rel="stylesheet" type="text/css" media="screen" href="<?php echo fileurl('/lib/js/jqgrid/css/ui.jqgrid.css');?>" /> <script src="<?php echo fileurl('/lib/js/jqgrid/js/i18n/grid.locale-en.js');?>" type="text/javascript"></script> <script src="<?php echo fileurl('/lib/js/jqgrid/js/jquery.jqGrid.min.js');?>" type="text/javascript"></script> <script type="text/javascript"> $("#grid").jqGrid({ url: '<?php echo adminaction('/pilotadmin/getpilotsjson');?>', datatype: 'json', mtype: 'GET', colNames: ['','First', 'Last', 'Email', 'Location', 'Status', 'Rank', 'Flights', 'Hours', 'IP', 'Edit'], colModel : [ {index: 'id', name: 'id', hidden: true, search: false }, {index: 'firstname', name : 'firstname',sortable : true, align: 'left', search: 'true', searchoptions:{sopt:['in']}}, {index: 'lastname', name : 'lastname', sortable : true, align: 'left', searchoptions:{sopt:['in']}}, {index: 'email', name : 'email', sortable : true, align: 'left',searchoptions:{sopt:['li']}}, {index: 'location', name : 'location', sortable : true, align: 'center',searchoptions:{sopt:['eq','ne']}}, {index: 'retired', name : 'status', sortable : true, align: 'center',searchoptions:{sopt:['in']}}, {index: 'rank', name : 'rank', sortable : true, align: 'center', searchoptions:{sopt:['eq','ne']}}, {index: 'totalflights', name : 'totalflights', sortable : true, align: 'center',searchoptions:{sopt:['lt','gt']}}, {index: 'totalhours', name : 'totalhours', sortable : true, align: 'center',searchoptions:{sopt:['lt','gt']}}, {index: 'lastip', name : 'lastip', sortable : true, align: 'center', searchoptions:{sopt:['in']}}, {index: '', name : '', sortable : true, align: 'center', search: false} ], pager: '#pager', rowNum: 25, sortname: 'lastname', sortorder: 'asc', viewrecords: true, autowidth: true, height: '100%' }); jQuery("#grid").jqGrid('navGrid','#pager', {edit:false,add:false,del:false,search:true,refresh:true}, {}, // edit {}, // add {}, //del {multipleSearch:true} // search options ); </script> Rather than copy all the code its just a simple name change on line 23 at the beginning, from status to retired Quote Link to comment Share on other sites More sharing options...
Guest lorathon Posted October 22, 2010 Report Share Posted October 22, 2010 If you would like the pilotid you have to change the pilotadmin/pilotadmin.php file also and then change the template again. Here is the code for this. This has also been tested on the clean install of the full version /admin/modules/PilotAdmin.php Line 362 $tmp = array( 'id' => $row->id, 'cell' => array( # Each column, in order $row->id, $row->pilotid, // Add this line to include the pilotid number in the table $row->firstname, $row->lastname, $row->email, $location, $status, $row->rank, $row->totalflights, $row->totalhours, $row->lastip, $edit, ), /admin/templates/pilots_list.tpl Change the entire template code to the following <h3>Pilots List</h3> <table id="grid"></table> <div id="pager"></div> <br /> <link rel="stylesheet" type="text/css" media="screen" href="<?php echo fileurl('/lib/js/jqgrid/css/ui.jqgrid.css');?>" /> <script src="<?php echo fileurl('/lib/js/jqgrid/js/i18n/grid.locale-en.js');?>" type="text/javascript"></script> <script src="<?php echo fileurl('/lib/js/jqgrid/js/jquery.jqGrid.min.js');?>" type="text/javascript"></script> <script type="text/javascript"> $("#grid").jqGrid({ url: '<?php echo adminaction('/pilotadmin/getpilotsjson');?>', datatype: 'json', mtype: 'GET', colNames: ['','Pilotid', 'First', 'Last', 'Email', 'Location', 'Status', 'Rank', 'Flights', 'Hours', 'IP', 'Edit'], colModel : [ {index: 'id', name: 'id', hidden: true, search: false }, {index: 'pilotid', name : 'pilotid',sortable : true, align: 'center', search: 'true', searchoptions:{sopt:['eq']}}, {index: 'firstname', name : 'firstname',sortable : true, align: 'left', search: 'true', searchoptions:{sopt:['in']}}, {index: 'lastname', name : 'lastname', sortable : true, align: 'left', searchoptions:{sopt:['in']}}, {index: 'email', name : 'email', sortable : true, align: 'left',searchoptions:{sopt:['li']}}, {index: 'location', name : 'location', sortable : true, align: 'center',searchoptions:{sopt:['eq','ne']}}, {index: 'retired', name : 'status', sortable : true, align: 'center',searchoptions:{sopt:['in']}}, {index: 'rank', name : 'rank', sortable : true, align: 'center', searchoptions:{sopt:['eq','ne']}}, {index: 'totalflights', name : 'totalflights', sortable : true, align: 'center',searchoptions:{sopt:['lt','gt']}}, {index: 'totalhours', name : 'totalhours', sortable : true, align: 'center',searchoptions:{sopt:['lt','gt']}}, {index: 'lastip', name : 'lastip', sortable : true, align: 'center', searchoptions:{sopt:['in']}}, {index: '', name : '', sortable : true, align: 'center', search: false} ], pager: '#pager', rowNum: 25, sortname: 'lastname', sortorder: 'asc', viewrecords: true, autowidth: true, height: '100%' }); jQuery("#grid").jqGrid('navGrid','#pager', {edit:false,add:false,del:false,search:true,refresh:true}, {}, // edit {}, // add {}, //del {multipleSearch:true} // search options ); </script> Quote Link to comment Share on other sites More sharing options...
Moderators mark1million Posted October 22, 2010 Moderators Report Share Posted October 22, 2010 Jeff you are a star, i was just looking at changing that as the pilot ID's are handy to see Quote Link to comment Share on other sites More sharing options...
Guest lorathon Posted October 22, 2010 Report Share Posted October 22, 2010 Modified Original Post once again. Should be good now. I left the pilotid column reference in. Quote Link to comment Share on other sites More sharing options...
Guest lorathon Posted October 22, 2010 Report Share Posted October 22, 2010 Jeff you are a star, i was just looking at changing that as the pilot ID's are handy to see Thanks Mark. I had been looking at this on and off for awhile now. Just couldn't get my head around it for some reason. And then it just clicked. Quote Link to comment Share on other sites More sharing options...
Moderators mark1million Posted October 22, 2010 Moderators Report Share Posted October 22, 2010 You are the man, working perfectly thank you for that fix. Quote Link to comment Share on other sites More sharing options...
Administrators Nabeel Posted October 22, 2010 Administrators Report Share Posted October 22, 2010 I'm going to move this to Code Snippets Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.