Max number of row ?
Max number of row ?
Hi,
I have a big database (mysql) with 35,000 rows. Problem is quite simple, when i use the server side processing option DataTables show 35000+ entries; i can browse every page and it works, but i want to limit the DataTables to 200 maximum results (some filtering option will be available to the client so he can optimize his research ... i think it could be done with fnDraw()).
How can i limit the DataTables to show only the first 200 rows ? (35000 rows found (200 displayed))
Thx
I have a big database (mysql) with 35,000 rows. Problem is quite simple, when i use the server side processing option DataTables show 35000+ entries; i can browse every page and it works, but i want to limit the DataTables to 200 maximum results (some filtering option will be available to the client so he can optimize his research ... i think it could be done with fnDraw()).
How can i limit the DataTables to show only the first 200 rows ? (35000 rows found (200 displayed))
Thx
This discussion has been closed.
Replies
$rResultFilterTotal = mysql_query($sQuery, $link) or die(mysql_error());
$aResultFilterTotal = mysql_fetch_array($rResultFilterTotal);
if ($aResultFilterTotal[0] > 200) { // add
$aResultFilterTotal[0] = 200;
}
$iFilteredTotal = $aResultFilterTotal[0];
But it seems when i click on a column header to sort it, DataTables pull all the data from the entire database (logic since the ordering is done while doing the select).
Then i tried to use "sAjaxSource": 'server_processing.php'.
I modify the server_processing file so it uses the same pattern as json_source.txt. It works :)
This way i could limit the request to the database :)
Again this plugin is wonderful ! Thx !
Nice one - good to hear you got this sorted. Thanks for posting the solution - I'm sure others will find it useful as well!
Regards,
Allan
Now i got a little problem with html links. I used the method described here (http://datatables.net/examples/advanced_init/html_sort.html) and i did this with the php source :
$sOutput .= "'".addslashes($aRow['browser'])."',";
But the problem is that the link is clickable in the php page while it is not in the text file (i think it is the problem). I tried to convert the output with htmlspecialchars but DataTables cannot read the json output. Any idea ?
update : nvm i found a solution : $sOutput .= "'".$aRow['browser']."',";
Another question :
I add a var at the start of my json output (juste before the aaData tag) "iRealTotal": 57 to get the real number of results from the mysql query. Now i must add code to your DataTables js to get this var. Do you know a quick way of doing it ?
update : nvm again :p i did it :)