CodeIgniter Forums
Default orderby when using rapyd datagrid - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Default orderby when using rapyd datagrid (/showthread.php?tid=5714)



Default orderby when using rapyd datagrid - El Forum - 02-01-2008

[eluser]Nathan Pitman (Nine Four)[/eluser]
Hi all. I've used CI a few times before and have just today discovered 'rapyd'. What an amazing piece of work! So quick and easy to display data etc but I have a quick query for anyone else out there that might know.

I have a datagrid which displays a number of columns all of which need to be sortable. This is no problem but how do I determine a 'default' orderby for the page?

Code:
$grid->column_orderby("ID","id","id");
$grid->column_detail("Company name","company_name", $link_edit);
$grid->column_orderby("Date","date","date");
$grid->column_orderby("Limit","limit_prod1","limit_prod1");
$grid->column_orderby("Used","used_prod1","used_prod1");

I can see that I could just check for the presence of 'orderby' in the relevant URL segment but is there a cleaner way to do it?


Default orderby when using rapyd datagrid - El Forum - 02-01-2008

[eluser]Nathan Pitman (Nine Four)[/eluser]
Well, I rolled my own very simple solution...

Code:
if ($this->uri->segment(3) != "orderby") {
    $grid->db->orderby("company_name");
}