Jump to content

Sorting Active/Inactive Pilots [SOLVED]


Guest lorathon

Recommended Posts

Guest lorathon

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>

Link to comment
Share on other sites

Guest lorathon

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 :D

Link to comment
Share on other sites

Guest lorathon

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)

Link to comment
Share on other sites

  • Moderators

OK so if your on a beta here is the code for you :lol:

<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

Link to comment
Share on other sites

Guest lorathon

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>

Link to comment
Share on other sites

Guest lorathon

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.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...