ptmuldoon
05-20-2008, 09:17 PM
I apologize if I should have perhaps posted this in the mysql forum. I Wasn't sure which one to post it in.
I'm using a datagrid that lets you set the a default column, and it will pull the data from your sql table and place it in a nice sortable grid. It seems to work very well thus far.
The datagrid is actually from here: http://stefangabos.blogspot.com
Now, I'm trying to modify the code some so that I can change the way the grid loads the first time, as I want it specify the ORDER BY to list in a specific order, and not simple ASC or DESC. From what I can tell, I believe I need to modify this section of the code.
// if the data needs to be sorted
if ($this->sortField != "") {
// append the sort string to the SQL
$this->source .= "
ORDER BY " . $this->sortField .
(strtolower($this->sortDirection) == "desc" ?
" DESC" :
""
) .
(trim($this->secondarySortColumns) != "" ? ", " . (trim(substr($this->secondarySortColumns, 0, 1)) == "," ? substr(trim($this->secondarySortColumns), 1) : trim($this->secondarySortColumns)) : "");
}
I've tried to manually change it, but it seems I can't get it work. And I'm trying to ORDER the grid on the page load to something like this:
ORDER BY field(state,'waiting','initial','playing','finished'), last_move DESC
I'm using a datagrid that lets you set the a default column, and it will pull the data from your sql table and place it in a nice sortable grid. It seems to work very well thus far.
The datagrid is actually from here: http://stefangabos.blogspot.com
Now, I'm trying to modify the code some so that I can change the way the grid loads the first time, as I want it specify the ORDER BY to list in a specific order, and not simple ASC or DESC. From what I can tell, I believe I need to modify this section of the code.
// if the data needs to be sorted
if ($this->sortField != "") {
// append the sort string to the SQL
$this->source .= "
ORDER BY " . $this->sortField .
(strtolower($this->sortDirection) == "desc" ?
" DESC" :
""
) .
(trim($this->secondarySortColumns) != "" ? ", " . (trim(substr($this->secondarySortColumns, 0, 1)) == "," ? substr(trim($this->secondarySortColumns), 1) : trim($this->secondarySortColumns)) : "");
}
I've tried to manually change it, but it seems I can't get it work. And I'm trying to ORDER the grid on the page load to something like this:
ORDER BY field(state,'waiting','initial','playing','finished'), last_move DESC