Home

Awesome

phalcon-data-table

This library allows you to simplify the interaction with the bootstrap-table in the Phalcon

Install

$loader = new \Phalcon\Loader();

$loader->registerNamespaces(
    [
        'Masvp' => APP_PATH.'/library/',
    ]);
    
$loader->registerDirs(
    [
        APP_PATH.'/library/',
    ]);

Sample

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,
            }, 
        ],
});

Simple result table

Documentation

information

bootstrap-table documentation

bootstrap-table select2 filter