Problem With Large Number of Columns

Problem With Large Number of Columns

aaronnmaaaronnma Posts: 3Questions: 0Answers: 0
edited January 2011 in General
First of all, I have to say that this project has some of the best documentation and support I've ever seen.

I'm using Datatables 1.7.5 and have everything working smoothly except for one issue:

I have a table that has over 50 columns. However, I've set it up so that it hides all but 8 by default by using aoColumns and bVisible.

The first time I click the button (which runs the server-side query) everything works smoothly and it's pretty fast. But if I want to change some search criteria and I click the button again (which does not refresh the page) it gets much, much slower.

I'm using bDestroy = true to destroy the table and redraw it without refreshing the page (so that all the form selections that the user has chosen are not erased).

After a bunch of testing, I figured out that this issue has to do with using aoColumns to hide the fields. If I remove the aoColumns settings (which means that all fields are shown by default), everything is fast no matter how many times the button is pressed.

I'm not sure if this makes any sense and I'm sorry it got so long.

I would post a link to the page where the error is occurring but unfortunately that's not an option (the table containse sensitive data).

I realize that this is kind of an obscure problem, but any help would be greatly appreciated.

Replies

  • allanallan Posts: 63,514Questions: 1Answers: 10,472 Site admin
    Hi aaronnma,

    Thanks for the post - sounds like an interesting problem. Do you see the slow down immediately when you click the button to reload the table? Or does it take a while - if it takes a while it is possible that there is a memory leak somewhere - particularly if you are using bDestroy (although I'm not sure where - otherwise I would have fixed it!).

    Are you ajax loading data in an array, or are you ajax loading the whole table - hence the need for bDestroy?

    Allan
  • aaronnmaaaronnma Posts: 3Questions: 0Answers: 0
    Hi Allan,

    Thanks for the quick response.

    Basically, I click the button and the browser seems to hang for few seconds before displaying the new results. It's like it's locking up the browser temporarily. Once it stops hanging, the table is displayed almost immediately.

    I basically followed the server-side example for PHP/MYSQL that you provided here: http://datatables.net/development/server-side/php_mysql and the server-side processing example from here: http://datatables.net/examples/data_sources/server_side.html

    I think I must be loading the whole table, because if bDestroy is not set to true, it displays a warning saying that it cannot reinitialize DataTable.

    Aaron
  • allanallan Posts: 63,514Questions: 1Answers: 10,472 Site admin
    Hi Aaron,

    You say "But if I want to change some search criteria and I click the button again" - which is fine of course, but it shouldn't need the whole table destroyed (unless you are showing a completely different table). How are you doing the filtering - is it with the DataTables filtering options (i.e. fnFilter)? This will automatically redraw the table for you when it's done the filter request from the table.

    Allan
  • aaronnmaaaronnma Posts: 3Questions: 0Answers: 0
    edited January 2011
    Allan,

    I'm actually using a custom form outside the DataTables system to build a query. Clicking the button then uses DataTables to display the data that the query comes back with.

    Here's a screenshot of what the custom form looks like:
    http://i.imgur.com/KQz8M.jpg

    I am using the Datatables filtering (the search box) to further drill down the results generated by the query if necessary.

    I'm not sure if that answered your question or not. If not, I can try to explain it a little better.

    I appreciate the time you're spending to help me out with this issue.

    Aaron
This discussion has been closed.