This is a migrated thread and some comments may be shown as answers.

Deselected rows in grid

1 Answer 284 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Maarten
Top achievements
Rank 1
Maarten asked on 17 Dec 2012, 11:50 AM
I can't work out how to get the deselected rows in the change() event in the grid? I can see that the select() method gives the rows that are selected but I can't see how to get the row that was just deselected ?

1 Answer, 1 is accepted

Sort by
0
Vladimir Iliev
Telerik team
answered on 18 Dec 2012, 02:33 PM
Hi Carl,

 
Please note that there is no build-in method which returns the deselected rows in the Change event, however you can implement such functionality by saving currently selected rows on each Change event and on next Change event compare them with the newly selected rows. Please find the example below:

Change event handler:

var lastSelection = [];
function onChange(e) {
    if (!lastSelection.length) {
        lastSelection = e.sender.select();
    }
    else {
        var currentSelection = e.sender.select();
        var deselected = [];
        for (var i = 0; i < lastSelection.length; i++) {
            currentUID = $(lastSelection[i]).attr("data-uid");
            if (!currentSelection.filter("[data-uid='" + currentUID + "']").length) {
                deselected.push(lastSelection[i]);
            }
        }
        lastSelection = currentSelection;
        //Execute your custom logic over the deselected rows
        console.log(deselected);
    }
}
Kind Regards,
Vladimir Iliev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Grid
Asked by
Maarten
Top achievements
Rank 1
Answers by
Vladimir Iliev
Telerik team
Share this question
or