Table rows data into an array
Table rows data into an array
goktuginal41@gmail.com
Posts: 57Questions: 22Answers: 0
Hello everyone,
When I type integer value of p_id_s in the text field and press enter, I want to collect the values of all rows in an array. However;
var lainArray = table.rows().data().toArray();
I can only get the value of 10 rows on on the screen page into an array. But with paging, there are more than 100 pages. Why can't I get all of them into an array? Thanks in advance.
$('#addsampleForm').on("keypress", "#p_id", function (e) {
if ( event.which == 13 && document.getElementById("p_id").value != '' ) {
$("#addsampleModal").modal('hide');
$("#sipCheckModal").modal('show');
var sip = document.getElementById("p_id").value;
var lainArray = table.rows().data().toArray();
......
$(document).ready(function() {
$('#records thead tr').clone(true).addClass('filters').appendTo('#records thead');
table = $('#records').DataTable({
'serverSide': true,
'ajax': '/api/base/?format=datatables',
{'data': 'p_id_s'},
.......
This question has an accepted answers - jump to answer
Answers
With server side processing (
serverSide: true
) the only rows at the client are those on the page. Therows()
API can only execute against the rows at the client. You can use jQuery ajax() to send a request to the server return the desired rows in a JSON response. However, fetching all the rows negates the performance gains of server side processing. Have you tried disabling SSP and using client side processing?Do you need server side processing enabled?
Kevin
Thank you Kevin,
I have around 4000 data and it can reach 6-7 thousand in time. It takes 30 seconds to load the page. That's why I wanted to try it with serverside = true. The time descreased 2-3 seconds, but I encountered the problem I mentioned above. Which way do you think makes sense for me to go?
That doesn't seem like much of a gain. My first step would be to find the bottleneck. Based on reducing the time just a few seconds I would say the bottleneck is in the server script.
Kevin