Sélect all onload

Sélect all onload

gmisterkgmisterk Posts: 4Questions: 2Answers: 0

Hi all
I use select extension .
I have a button selectAll. .and It works fine.
By défaut nothing is selected and I want inverse.

I.m trying to select all items onload (when document ready)

I have tried this : $('#myid').addClass('selected'); but whiout success

Any suggestion?

Thanks for your Help.


  • colincolin Posts: 4,694Questions: 0Answers: 823

    Hi @gmisterk ,

    The best bet is to use initComplete, this will get called when the table has fully loaded. You can do something like this:

          initComplete: function() {

    See this live example.



  • jshuffjshuff Posts: 1Questions: 0Answers: 0

    This was very helpful in getting me started. Any suggestions on how to have it select only specific rows instead of all?

    My objective is that I'm setting this up for a user to UPDATE an existing record in the database. I have the complete form loaded and pre-populated with the existing database values.

    What I need to accomplish is now AFTER LOAD my datatable shows all US States but I need to auto select New York and California. My JSON that populates the datatable has an additional attribute name 'active' which is set to '1' for the rows I'd like to auto select.

    Any ideas?

  • kthorngrenkthorngren Posts: 5,544Questions: 19Answers: 1,233

    Good question. The solution I would use makes use of rows().indexes() and filter(). Inside initComplete a combo of those APIs is used to build an array of indexes containing the rows with active === 1. The indexes is then used to select the rows to select using rows().select(). Here is an example selecting all rows where the Office is London.


Sign In or Register to comment.