primefaces / primeui

Rich set of javascript-css only widgets
http://www.primefaces.org/primeui
285 stars 125 forks source link

getSelection in puidatatable does not work if first row is selected #153

Closed trickysan closed 8 years ago

trickysan commented 8 years ago

If the first row in puidatatable is selected, the call of "getSelection" returns an empty result. It only works starting with the second row.

Reproduction of issue:

cagataycivici commented 8 years ago

Replicated

aozkesek commented 8 years ago

Hi Cagatay,
The fix seems easy, I've tested this fix on datatableselection.html with both single and multiple, and on datatable.html with remote lazy table after add single selection and then multiple selection feature to it.

Would you review, test too?

I've just changed greater than operator to greater than or equal operator in datatable.js in getSelection function ;

            for(var i = 0; i < this.selection.length; i++) {
                 if(this.data.length > this.selection[i]-first && this.selection[i]-first >= 0) {

The only thing I concern is what happen on multiple selection maden from different page of lazy, current situation gets only selections of the current page,

trickysan commented 8 years ago

The fix from @aozkesek works for me as expected.

cagataycivici commented 8 years ago

I'm rewriting the selection impl to fix this and a couple of other issues for 4.1.1.

cagataycivici commented 8 years ago

Fixed for 4.1.1.