Welcome Guest, Not a member yet? Register   Sign In
Default orderby when using rapyd datagrid
#1

[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?
#2

[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");
}




Theme © iAndrew 2016 - Forum software by © MyBB