Count of selected rows.

Count of selected rows.

ArunRahulArunRahul Posts: 16Questions: 4Answers: 0
edited April 2014 in TableTools
In my code I am using two custom(not table tools provided) buttons which selects and deselects all the rows in table.I am calling fnSelectAll() and fnSelectNone() respectively for those button click callbacks. Also I can induvidually select multiple rows in the table.
Is there a way/technique through which I can get the count of selected rows ? Could any one help me on this ?
I tried to implement it with one variable which gets incremented when I select any row (I am incrementing the count at fnRowSelected callback) and gets decrement when I de-select any row (I am decrementing the count at fnRowDeselected callback). As I am implementing custom buttons to select and deselect all I tried the same in those button click callbacks also . But it didn't work.

Replies

  • allanallan Posts: 61,972Questions: 1Answers: 10,160 Site admin
    Use `fnGetSelected().length` - http://datatables.net/extras/tabletools/api#fnGetSelected

    Allan
  • ArunRahulArunRahul Posts: 16Questions: 4Answers: 0
    But I have to call it multiple times at multiple places. Would it affect performance?
  • allanallan Posts: 61,972Questions: 1Answers: 10,160 Site admin
    Unless you have tens of thousands of selected rows, I doubt you'd ever notice. But the only way to be certain is to try it and profile it.

    Allan
  • ArunRahulArunRahul Posts: 16Questions: 4Answers: 0
    Ok. Thanks Allan
This discussion has been closed.