ORDER

ORDER

nskwortsownskwortsow Posts: 120Questions: 0Answers: 0
edited November 2012 in General
Hi,

How do I order the search results (in this case: EquipmentName ASC)?

$editor = Editor::inst( $db, 'tblExerciseEquipment' )
->fields(
Field::inst( 'EquipmentName' )->validator( 'Validate::required' ),
Field::inst( 'f_LanguageID' )->validator( 'Validate::required' )
)
->join(
Join::inst('tblLanguages','object')
->join('f_LanguageID','LanguageID')
->fields(
Field::inst( 'LanguageID' ),
Field::inst( 'LName' ))
->set( false )
);

Replies

  • allanallan Posts: 63,531Questions: 1Answers: 10,474 Site admin
    Ordering is done by DataTables on the client-side - so it should just happen automatically. Does it not?

    Allan
  • nskwortsownskwortsow Posts: 120Questions: 0Answers: 0
    It does, but with a large dataset, SQL is more efficient.
  • allanallan Posts: 63,531Questions: 1Answers: 10,474 Site admin
    Yes it is - but you need to either pick client-side processing or server-side processing - there cannot be a mix of the two. The php classes in Editor 1.2.2 will automatically work with server-side processing if you are using them - just enable bServerSide

    Allan
  • nskwortsownskwortsow Posts: 120Questions: 0Answers: 0
    OK, but why do you have the public ORDER method?
    http://editor.datatables.net/docs/current/php/class-DataTables.Database.Query.html
  • allanallan Posts: 63,531Questions: 1Answers: 10,474 Site admin
    The Database class has a public `order` method, but the Editor class does not. The Editor class uses the Database class in order to query the database (its a database abstraction layer) - so it must be public for that, but that functionally is not exposed through the Editor class. It could be added, but given that the client-side will do a sort anyway, it wouldn't really be of any benefit.

    Allan
This discussion has been closed.