Documentation for phalcon-data-table
May 5, 2019 ยท View on GitHub
class constructor
$creator $creator = new MySqlCreater($model, $configuration)
$model - \Phalcon\Mvc\Model link1
link2
$configuration - configuration array
configuration array
'columns' [array|string] - columns access (required)
// for string
$config['columns'] = "id,usersId,ipAddress,type,createdAt";
// for array
$config['columns'] = ["id","usersId","ipAddress","type","createdAt"];
's_columns' [array|string] - columns access. If no 's_columns' in config, filters off. Filters info: bootstrap-table select2 filter
Used to create a query by type "column1 LIKE :bind_param1: AND column2 LIKE :bind_param2:", which allows the use of % and _ in the query
// for string
$config['s_columns'] = "ipAddress,type";
// for array
$config['s_columns'] = ["ipAddress","type"];
'search_column' [string] - column for search ('%'.value.'%').
If no 'search_column' in config, search off.
(link)
$config['search_column'] = "ipAddress";
'conditions' [array] - conditions (Can't be used without 'bind').
'bind' [array] - bind values for conditions (Can not be used without 'conditions')
$config['conditions'] = ['usersId = :user_id:'];
$config['bind'] = ['user_id' => $user->id];
'data' [array] - request for bootstrap table (required)
$config['data'] = $this->request->getPost();
'max_rows' [array] - maximum rows of query (limit).
To protect against receiving large amounts of data from the database on the server side.
$config['max_rows'] = 1000;
Simple
php
$model = new ResetPasswords();
$creator = new MySqlCreater($model, [
'columns' => 'id,usersId,ipAddress,type,createdAt',
's_columns' => 'ipAddress',
'conditions' => ['usersId = :user_id_con:'],
'bind' => ['user_id_con' => $user->id],
'data' => $this->request->getPost(),
]);
return $this->response->setJsonContent($creator->getResult());
html
<table
id="table-reset-passwords"
class="table table-hover"
data-toolbar="#toolbar"
data-show-refresh="true"
data-show-toggle="true"
data-show-fullscreen="true"
data-show-columns="true"
data-show-export="true"
data-minimum-count-columns="1"
data-show-pagination-switch="true"
data-pagination="true"
data-id-field="id"
data-sort-name="createdAt"
data-sort-order="desc"
data-page-list="[5, 10, 25]"
data-side-pagination="server"
data-url="/admin/users/api/reset-passwords/get/{{ USER.id }}"
data-method="POST"
data-content-type="application/x-www-form-urlencoded">
</table>
javascript
$('#table-reset-passwords').bootstrapTable('destroy').bootstrapTable({
locale : 'ru-RU',
filter : true,
columns: [
{
field : 'id',
title : 'ID',
sortable : true,
align : 'center',
},
{
field : 'userId',
title : 'User ID',
sortable : true,
align : 'center',
},
{
field : 'ipAddress',
title : 'IP',
sortable : false,
align : 'center',
filter: {
type:'input'
},
}, {
field : 'type',
title : 'Type',
sortable : false,
align : 'center'
}, {
field : 'createdAt',
title : 'Date',
sortable : true,
align : 'center',
formatter: unixTimeFormater,
},
],
});
