Sortable

Warning If you use a sortable together with a pager of filter, sortable will not work correctly.

Method enableSortable

  • $columnName is the name of the column you want to sort
$grid->enableSortable($columnName);

Event onSort fired if is something sorted

Info See onSorton events page

Usage

$mesourApp = //instance Mesour\Components\Application\IApplication
$source = //some <a href="http://components.mesour.com/version3/component/sources/" target="_blank">data source</a> or two-dimensional array

$grid = new Mesour\UI\DataGrid('filterDataGrid', $mesourApp);

$grid->setSource($source);

//! here enable sortable extension
$grid->enableSortable('sort');

//! here use sortable callback
$grid->onSort[] = function (array $sortArr, $currentMovedId) {
    //! do some SQL for save sort
};

$grid->addText('name', 'Name');

$grid->addText('surname', 'Surname');

$grid->addText('email', 'E-mail');

$grid->render();

Demo


NameSurnameE-mail
JohnDoejohn.doe@test.xx
PeterLarsonpeter.larson@test.xx
ClaudeGravesclaude.graves@test.xx
StuartNormanstuart.norman@test.xx
KathyArnoldkathy.arnold@test.xx
JanWilsonjan.wilson@test.xx
AlbertaEricksonalberta.erickson@test.xx
AdaWellsada.wells@test.xx
EthelFigueroaethel.figueroa@test.xx
IanGoodwinian.goodwin@test.xx
FrancisHayesfrancis.hayes@test.xx
ErmaBurnserma.burns@test.xx
KristinaJenkinskristina.jenkins@test.xx
VirgilHuntvirgil.hunt@test.xx
MaxMartinmax.martin@test.xx
MelodyManningmelody.manning@test.xx
CatherineToddcatherine.todd@test.xx
DouglasStanleydouglas.stanley@test.xx
PattiDiazpatti.diaz@test.xx
JohnPettersonjohn.petterson@test.xx