sorting own columns when using server side processing

sorting own columns when using server side processing

TKingTKing Posts: 3Questions: 0Answers: 0
edited March 2010 in General
hey allan,

my problem is that I cant sort my own columns. I have 10 columns - 9 of them are server side and 1 depends on a server side column. This column can have the value "read" or "unread".

Can I sort this column somehow? If I try to sort this column it stucks at processing..

I tried to realise it this way:

in this part[code]while ( $aRow = mysql_fetch_array ( $rResult ) ) {[/code]

i give arow a new column with the value unread or read and give it to sOutput:

[code]
if ($messageDAO->isSupportUnreadByIDandUserID ( $aRow ['support_id'], $User->getUserID () ))
$aRow ['readOrUnread'] = "unread";
else
$aRow ['readOrUnread'] = "read";

$sOutput .= '"' . addslashes ( $aRow ['readOrUnread'] ) . '",';
[/code]

in the function fnColumnToField I let the value of aRow['readOrUnread'] return like this:
[code]
function fnColumnToField($i) {
..
else if ($i == 2)
return "readOrUnread";
..}
[/code]

can u tell me if my approach is wrong because i think i didnt understand the sense of fncolumntofield at all..


thank you in advance

TKing

Replies

  • emjay2emjay2 Posts: 10Questions: 0Answers: 0
    fnColumnToField is just being used to switch the index to the correct column name for sorting.

    Using server side processing, you have to handle the sort in your server side code as well (in this case by applying an order by to your query), so unless the column readOrUnread was in your query, it wouldn't work.
  • TKingTKing Posts: 3Questions: 0Answers: 0
    so is there any possibility to do sth like that i wanted??
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Yes it is possible - but it is considerably more complicated than the sorting done in the SQL engine. Because it's doing all the sorting for you - that's working well - however, if it doesn't know anything about the sorting for the 'read' column - that you are going to run into problems. For example you might only have one 'Read' entry in 1000 results, and if you click to sort on that column, then you would expect it to be at the top - but if SQL doesn't see anything about that, then you are going to have to dump the entire data set, do the sort and filer yourself. Nasty.

    Can you do an SQL JOIN to get the sorting correct or something - or is this informaiton simply not present in the SQL at all?

    Allan
This discussion has been closed.