Download the PHP package rashedalkhatib/yii2-datatables without Composer

On this page you can find all versions of the php package rashedalkhatib/yii2-datatables. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package yii2-datatables

DataTable Widget

Overview

The DataTable widget is used to create interactive and dynamic data tables. The provided JavaScript code demonstrates how to initialize DataTable with server-side processing, custom data handling, and column rendering and with full serverside Export .

installation

in your Yii2 application :

// Define your DataTable columns $columns = [ [ 'title' => 'ID', 'data' => 'id', 'visible' => true, 'render' => new JsExpression('function(data, type, row) { return "demo"; }'), ], ];

// Configure other DataTable parameters $processing = true; $serverSide = true; $pageLength = 10; $dom = 'Btip'; $buttons = [ [ 'extend' => 'excel', 'text' => 'Excel', 'titleAttr' => 'Excel', 'action' => new JsExpression('exportAll') // this is required ], ];

// Configure Ajax settings $ajaxConfig = [ 'url' => $ajaxUrl, 'bdestroy' => true, 'type' => 'POST', 'data' => new JsExpression('function(d) { var searchForm = $('body').find('#searchForm').serializeArray();

        searchForm[searchForm.length] = { name: 'YourModel[page]', value: d.start }; // required
        searchForm[searchForm.length] = { name: 'YourModel[length]', value: d.length }; // required
        searchForm[searchForm.length] = { name: 'YourModel[draw]', value: d.draw }; // required

        var order = {
            'attribute': d.columns[d.order[0]['column']]['data'],
            'dir': d.order[0]['dir']
        }; // required

        searchForm[searchForm.length] = { name: 'YourModel[order]', value: JSON.stringify(order) };
        return searchForm;
}'),
'dataSrc' => new JsExpression('function(d) {
    var searchForm = $("' . $searchFormSelector . '").serializeArray();
    if (d.validation) {
        searchForm.yiiActiveForm("updateMessages", d.validation, true);
        return [];
    }
    return d.data;
}'),

];

// Use the DataTableWidget with configured parameters DataTable::widget([ 'id' => 'yourDataTable', 'ajaxConfig' => $ajaxConfig, 'columns' => $columns, 'processing' => $processing, 'serverSide' => $serverSide, 'pageLength' => $pageLength, 'dom' => $dom, 'buttons' => $buttons, ]);

// The HTML container for your DataTable echo '

// your inputs
'; echo '
'; html

// your inputs

javascript var arrayToExport = [0,1]; $('#yourDataTable').DataTable({ "ajax": { // Server-side processing configuration "url": "../api/yourEndPoint", "bdestroy": true, // this allows you to re init the dataTabel and destory it "type": "POST", // request method "data": function (d) { // this represent the data you are sending with your ajax request // Custom function for sending additional parameters to the server var searchForm = $('body').find('#searchForm').serializeArray();

        searchForm[searchForm.length] = { name: "YourModel[page]", value: d.start }; // required
        searchForm[searchForm.length] = { name: "YourModel[length]", value: d.length }; // required
        searchForm[searchForm.length] = { name: "YourModel[draw]", value: d.draw }; // required

        var order = {
            'attribute': d.columns[d.order[0]['column']]['data'],
            'dir': d.order[0]['dir']
        }; // required

        searchForm[searchForm.length] = { name: "YourModel[order]", value: JSON.stringify(order) };
        return searchForm;
    },
    dataSrc: function (d) {
        // Custom function to handle the response data
        // EX:
        var searchForm = $('body').find('#searchForm').serializeArray();
        if (d.validation) {
            searchForm.yiiActiveForm('updateMessages', d.validation, true);
            return [];
        }
        return d.data;
    }
},
"columns": [{
    // Column configurations
    "title": "ID",
    "data": "id",
    "visible": true // visablity of column 
},
// ... (other columns)
{
    "title": "Actions",
    "data": "id",
    "visible": actionCol,
    "render": function (data, type, row) {
        // Custom rendering function for the "Actions" column
        return '<a class="showSomething" data-id="' + row.id + '">View</a>';
    }
}],
processing: true,
serverSide: true,
"pageLength": 10,
dom: "Btip",
"buttons": [{
    // "Excel" button configuration
    "extend": 'excel',
    exportOptions: {
        columns: arrayToExport
    },
    "text": '  Excel',
    "titleAttr": 'Excel',
    "action": exportAll // newexportaction this action is to allow you exporting with server side without rendaring data 
}],

}); injectablephp // in your HTTP request you want to include these params $_postData = [ 'page' => $this->page == 0 ? 0 : $this->page / $this->length, // this equation is required to handle Yii2 Data provider Logic 'limit' => $this->length, 'export' => $this->export, 'order' => $this->order, // add your custom params ..... ]; injectablephp public function actionYourEndPoint() {

    $searchModel = new SearchModel();

    $dataProvider = $searchModel->search(Yii::$app->request->get());
    return $this->asJson(
        array(
            'data' => $dataProvider['data'],
            'count' => $dataProvider['count']
        )
    );

}

injectablephp public function search($params) { $this->load($params, ''); // load your values into the model $query = Data::find(); // Data model is your link to the database

    $_order = json_decode($this->order);
    if ($this->export == 'true') {
        $dataProvider = new ActiveDataProvider([
            'query' => $query
            // we removed the page and pageSize keys to allow all data to be exported
        ]);
    } else {
        $_orderType = SORT_ASC;
        if ($_order->dir == 'desc')
            $_orderType = SORT_DESC;
        $query->orderBy([$_order->attribute => $_orderType]);
        $dataProvider = new ActiveDataProvider([
            'query' => $query,
            'pagination' => [
                'pageSize' => $this->limit,
                'page' => $this->page,
            ],
        ]);
    }

    return array(
        'data' => $dataProvider->getModels(),
        'count' => $dataProvider->getTotalCount()
    );
}


## Feel Free to contact me : [email protected]

All versions of yii2-datatables with dependencies

PHP Build Version
Package Version
Requires yiisoft/yii2 Version *
bower-asset/jquery Version >= 1.7.0
bower-asset/datatables Version >= 1.9.4
bower-asset/datatables-bootstrap3 Version *
bower-asset/datatables-tabletools Version *
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package rashedalkhatib/yii2-datatables contains the following files

Loading the files please wait ....