Datatables getting slow in processing options for one to many join tables

Datatables getting slow in processing options for one to many join tables

HarinandanHarinandan Posts: 4Questions: 2Answers: 0

Hello,

I followed https://editor.datatables.net/manual/php/mjoin#Mjoin-class and set up one to many joins. The many values form options for a checkbox. If I provide options in server side, datatables is taking too much time to load the table.

If I omit providing options, it loads quicker but inline bubble editing of that column will not show existing set values as selected. All checkboxes show up as empty. But the next time user clicks on the column, inline bubble editing will show up options selected as checked correctly.

Any idea what is happening here?

Regards,
Harinandan

Answers

  • allanallan Posts: 63,455Questions: 1Answers: 10,465 Site admin

    Hi Harinandan,

    Could you link to a page showing the issue so I can take a look please?

    Thanks,
    Allan

  • HarinandanHarinandan Posts: 4Questions: 2Answers: 0

    Hi Allan,

    It is little difficult to recreate it stand alone since there is private data. But basically I'm just following https://editor.datatables.net/examples/advanced/joinArray.html.

    But in server script, in Mjoin, if I have options as below

    ->options( Options::inst()
    ->table( 'permission' )
    ->value( 'id' )
    ->label( 'name' )
    ),

    it takes a lot of time to load the tables since I have several thousand options. However, it functions as expected if I include this.

    But if I omit options, tables load faster and is usable. I am using bubble editing and loading options using dependent since they depend on another column. It is in this case that when options are shown with checkboxes as in example, none are selected at first. Second time if clicked to edit, they are fine.

    Any idea what can be done? Looks like first time its loading options and next time it knows them.

    Regards,
    Harinandan

  • allanallan Posts: 63,455Questions: 1Answers: 10,465 Site admin

    Hi Harinandan,

    If its the Options() which is causing the issue, perhaps it would be worth trying to add a limit() (see the docs here) to limit the number of options.

    Alternatively, if you want the end user to be able to select any value (not just a limited subset), then you might consider using the Select2 integration for Editor. It can make Ajax calls to the server based on user input information (i.e. typeahead).

    Allan

This discussion has been closed.