Библиотека обработки данных SSP на стороне сервера
Мне нужно использовать функцию заказа в библиотеке SSP, которая используется для обработки на стороне сервера в таблице данных. Я не знаю, как передать столбец, с которым мне нужно упорядочить результат.
// DB table to use
$table = 'crowd_sourcing_products';
// Table's primary key
$primaryKey = 'id';
// Array of database columns which should be read and sent back to DataTables.
// The `db` parameter represents the column name in the database, while the `dt`
// parameter represents the DataTables column identifier. In this case simple
// indexes
$columns = array(
array('db' => `p` . 'id', 'field' => 'id', 'dt' => 'DT_RowId', 'formatter' => function( $d, $row ) {
// Technically a DOM id cannot start with an integer, so we prefix
// a string. This can also be useful if you have multiple tables
// to ensure that the id is unique with a different prefix
return 'row_' . $d;
}),
array('db' => `c` . 'barcode', 'dt' => 0, 'field' => 'barcode'),
array('db' => `c` . 'package_front_image', 'dt' => 1, 'field' => 'package_front_image', 'formatter' => function( $d, $row ) {
return '<img src ="'.base_url().'mobilesup/images/' . str_replace('"', '', $d) . '">';
}),
array('db' => `c` . 'label1', 'dt' => 2, 'field' => 'label1', 'formatter' => function( $d, $row ) {
return '<img src ="'.base_url().'mobilesup/images/' . str_replace('"', '', $d) . '">';
}),
array('db' => `c` . 'label2', 'dt' => 3, 'field' => 'label2', 'formatter' => function( $d, $row ) {
return '<img src ="'.base_url().'mobilesup/images/' . str_replace('"', '', $d) . '">';
}),
array('db' => `c` . 'net_weight', 'field' => 'net_weight', 'dt' => 4),
array('db' => `nu` . 'unit_e_value', 'field' => 'unit_e_value', 'dt' => 5)
// array( 'db' => 'net_weight', 'dt' => 3 )
);
$joinQuery = "FROM `crowd_sourcing_products` AS `c` left JOIN `nutrition_facts_unit` AS `nu` ON (`c`.`unit_id` = `nu`.`unit_id`)";
$extraWhere = "`c`.is_deleted <> '1's";
$this->load->library('Ssp');
SSP::order($_GET, $columns); ////// how to use it??????????
echo json_encode(
SSP::simple($_GET, $sql_details, $table, $primaryKey, $columns, $joinQuery ,$extraWhere )
);
}
1 ответ
Использование order
опция на стороне клиента вместо того, чтобы указать начальный порядок для таблицы.
Например:
$('#example').DataTable({
"order": [[ 1, 'asc' ]]
});