Server side processing
Server side processing
First thx for this good pice of software!!
I have one querstion how i make my server side php to make both working
Show the table right
Use the editor
Next server side php is working for editor but some functions like sorting is not working any more:
```php
<?php
use
DataTables\Editor,
DataTables\Editor\Field,
DataTables\Editor\Format,
DataTables\Editor\Join,
DataTables\Editor\Validate;
Editor::inst( $db, 'computer' )
->fields(
Field::inst( 'type' )
->validator( 'Validate::notEmpty' ),
Field::inst( 'os' )
->validator( 'Validate::notEmpty' ),
Field::inst( 'arch' )
->validator( 'Validate::notEmpty' ),
Field::inst( 'name' )
->validator( 'Validate::notEmpty' ),
Field::inst( 'ip' )
->validator( 'Validate::notEmpty' ),
Field::inst( 'mac' )
->validator( 'Validate::notEmpty' ),
Field::inst( 'dashboard' )
->validator( 'Validate::notEmpty' )
)
->process( $_POST )
->json();
This is working to show all data perfect but editor is not wokring any more:
```php
<?php
$table = 'computer';
$primaryKey = 'id';
$columns = array(
array( 'db' => 'type', 'dt' => "type" ),
array( 'db' => 'os', 'dt' => "os" ),
array( 'db' => 'arch', 'dt' => "arch" ),
array( 'db' => 'name', 'dt' => "name" ),
array( 'db' => 'ip', 'dt' => "ip" ),
array( 'db' => 'mac', 'dt' => "mac" ),
array( 'db' => 'dashboard', 'dt' => "dashboard" ),
);
$sql_details = array(
'user' => '****',
'pass' => '****',
'db' => 'skybot-home',
'host' => 'localhost'
);
require( 'ssp.class.php' );
echo json_encode(
SSP::simple( $_GET, $sql_details, $table, $primaryKey, $columns)
);
So my querstion is witch one is right?
Thank you so much for help ;)
This question has an accepted answers - jump to answer
Answers
ok more then 80 eur, is not enough to get a little hint :(
ok will tray my best to solve it :(
Hi,
Sorry for the delay in replying over the weekend.
Editor has server-side processing support built in - you just need to direct the Ajax request that DataTables makes at the Editor PHP script. You don't need a separate one! Likely you will also want to have DataTables make its Ajax request using
POST
rather than the defaultGET
.There is an example of DataTables using server-side processing on the Editor site, which makes use of this ability of the libraries.
Let me know how you get on with it!
Allan
I understand and i know this example side: but if i use this code i can use the editor 100% but some features like sorting are not working in datatables any more.
options[]
i dont get valuses in JSON replay so datatables dont know how much rows and so on ...
Are you able to link me to the page you are working on so I can take a look and see what is going wrong? As you can see from the example I linked to, server-side processing with the Editor libraries should support sorting and filtering no problem.
Allan
http://skybot.mine.nu:8100/#ajax/setup/computer.php
please have a look
and thank you
Hi,
The Ajax requests that DataTables is making are
GET
, and notPOST
as I suggested you probably want.Editor is expecting the data as
POST
(from your code above:->process( $_POST )
) .Line 36 in the code below the table in the example I linked to shows how you can have DataTables make a POST request for the data.
Allan
p.s. Nice design btw :-)
DataTables warning: table id=computer_table - SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '-1' at line 1
:(
ok got it ;)