Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

This api help to datatables server-side integrations by SSP code otimized

NotificationsYou must be signed in to change notification settings

minasvisual/datatables-js-server-api

Repository files navigation

This api help to datatables server-side integrations by SSP code otimized

#How to use:

Config:

required 'path/to/Datatables.php';

//set config connections and requests$config['config'] = array('user' => 'user','pass' => 'pass','db' => 'db name','host' => 'host');

$dt = new Datatables( $config );

Adding columns

//addCols($field, $alias=null, $params=array(), $dt=null ) $dt->addCols( 'post_id', 'p' );// or$dt->addCols( array( array('title', 'p' ),array('category', 'c', ['as'=>'cat'] ),array('created_at', 'p',       array( 'formatter' => function( $d, $row ) {            return array( 'display'=>date( 'd/m/Y', strtotime($d) ), 'timestamp'=>$d ); // output formated        }))) // end params);

Adding tables ( required least 1 )

// addTables(  $table, $key='id', $alias  )$dt->addTables( 'posts', 'post_id', 'p');//or$dt->addTables( array(array( 'categories', 'category_id', 'c' ),...));

Adding joins (new method linked)

// addJoin( $join_table, $join_pk, $join_alias, $fk, $join_type='', $target_alias=null )$dt->addTables( 'posts', 'id', 'p')->addJoin('users', 'id', 'u', 'user_id', 'LEFT')->addJoin('users','id','a','autor')

Add additional where

// addWhere($field, $value='', $alias=null, $op='=', $concat='and' )$dt->addWhere( 'created_at', $_POST['initdate'], 'p', '>=' );or $dt->addWhere(         array(          array( 'created_at', $_POST['initdate'], 'p', '>='),          ....        )      );

Show return:

echo json_encode( $dt->render() );

Javascript render helper

//renderJS( $selector, $params, $lang=null, $urlParams=null, $inst='table' )$dt->renderJS("#table",            // html selector table   '"processing": true, // server side"serverSide": true,  // server side"ajax": {            // data source"url": "path/to/data","type": "GET"    // Use POST if you prefer},"columnDefs": [      // columns modifications            {  targets: 2, render: { _: "display",  sort: "timestamp"  }  }, //get date formated    ],',null,                // Language json file (Default portuguese-br) | see doc https://datatables.net/plug-ins/i18n/array( "param" => '$("#input").val()',   // additional url parameters to filter data source    ),);
Outputs basic javascript call

For javascript configuration and server side working seehttps://datatables.net/;

About

This api help to datatables server-side integrations by SSP code otimized

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp