rampesna/jqx-server-side

JQX Server Side is a PHP library that helps you to create a server side for JQX DataTables.

v1.1.0 2023-10-17 12:41 UTC

This package is auto-updated.

Last update: 2024-10-17 14:52:28 UTC


README

This package has been meticulously designed to optimize JqxGrid for server-side operations for Laravel and other PHP projects. With this integration, users can now seamlessly manage vast datasets and improve overall performance. Harness the full potential of JqxGrid with our specialized server-side solution.

Total Downloads GitHub repo size Build

Requirements

  • PHP >= 8.0
  • Illuminate/Database >= 8.0
  • Illuminate/Htpp >= 8.0

Installation

composer require rampesna/jqx-server-side

Usage

Controller

use Rampesna\JqxGrid;

class ExampleController extends Controller
{
    public function index(Request $request)
    {
        $tableName = 'your_table_name';
        $columns = [
            'id',
            'name',
            'surname',
            // ...
        ];
        
        $jqxGrid = new JqxGrid(
            $tableName,
            $columns,
            $request
        );
        
        return response()->json($jqxGrid->initialize());
    }
}

View

var yourGridDiv = $('#your-grid-div');

var source = {
    datatype: "json",
    datafields: [
        {name: 'id', type: 'integer'},
        // your columns ...
    ],
    cache: false,
    url: 'your_controller_url',
    beforeSend: function(xhr) {
        // if you need to send authorization token
        xhr.setRequestHeader('Authorization', 'Bearer ' + your_token);
        xhr.setRequestHeader('Accept', 'application/json');
    },
    beforeprocessing: function (data) {
        source.totalrecords = data[0].TotalRows;
    },
    root: 'Rows',
    filter: function () {
        yourGridDiv.jqxGrid('updatebounddata', 'filter');
    },
    sort: function () {
        yourGridDiv.jqxGrid('updatebounddata');
    }
};

var dataAdapter = new $.jqx.dataAdapter(source);

yourGridDiv.jqxGrid({
    // other options ...
    source: dataAdapter,
    filterable: true,
    showfilterrow: true,
    pageable: true,
    sortable: true,
    virtualmode: true,
    rendergridrows: function (params) {
        return params.data;
    },
    columns: [
        {
            text: '#',
            dataField: 'id',
            columntype: 'textbox',
        },
        // your columns ...
    ],
});

License

MIT License