Row Selected Count

Row Selected Count

fliesflies Posts: 35Questions: 0Answers: 0
edited July 2009 in Bug reports
First of all I would like to say that I am really impressed with your work.

Secondly, today I ran into a slight problem. I was using your getselected function from one of the examples, and the problem is, when i delete row and then count the selected rows i get the same amount. There is a very easy solution to this, just removeClass after deleting.

Hope it will help someone, or maybe you will make a seperate array for deleted rows instead of aoData?

Replies

  • allanallan Posts: 63,692Questions: 1Answers: 10,500 Site admin
    Hi flies,

    What you can do (in DataTables 1.5) is pass a third argument to fnDeleteRow(), which is boolean and if true it will set the value of the internal data array to null for that column.

    The reason the data is retained normally is that with the the internal data array of DataTables the position is very important, so the rows can't just be deleted from the array (fnGetPosition() etc also require those the array indexes to be maintained). However with this new third parameter you can at least go some distance to being able to see what has been deleted (do a loop looking for != null).

    Hope this helps,
    Allan
  • fliesflies Posts: 35Questions: 0Answers: 0
    Well I don't want to delete data from internal array, cause I give users option to cancel all changes on quit. Nulling tr will make it impossible. That's why I though of different table, or maybe there is some kind of variable which makes it easier for checking if row was deleted or not? Maybe I can achieve this with array diff?
  • allanallan Posts: 63,692Questions: 1Answers: 10,500 Site admin
    Ah ha - and this is exactly one of this things where I thought that not deleting the internal data array might actually be useful - reinserting the rows. Interesting one. So what you need to do is more or less as you suggest - keep an array of indexes for rows which have been deleted, and the remove those indexes (i.e. diff two arrays) from the array you want to work on (a clone of the aoData array).

    Regards,
    Allan
This discussion has been closed.