using 'row_selected'

using 'row_selected'

barrykeepencebarrykeepence Posts: 22Questions: 0Answers: 0
edited June 2013 in General
I use the 'row_selected' class all the time and generally it works very well. I have tables with single select and multi select behaviour - based on samples from the web site.

I have just realised there is a problem with using 'row_selected' with filtering. Basically if I want to enforce single row selection I use:
[code]
$(my table selector).removeClass('row_selected');
$(this).addClass('row_selected');
[/code]
This works fine except when the table is filtered - if the filtering has removed a previously selected row then the first line of the code will not remove the class.

How can I remove a class from all rows?

Replies

  • allanallan Posts: 63,516Questions: 1Answers: 10,472 Site admin
    Use the $ API method - http://datatables.net/docs/DataTables/1.9.4/DataTable.html#$ .

    [code]
    table.$('tr.row_selected').removeClass( 'row_selected' );
    [/code]

    Allan
  • barrykeepencebarrykeepence Posts: 22Questions: 0Answers: 0
    Thanks
    I never used the $ function much before but know I know it is independent of filtering I will use it more.
This discussion has been closed.