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

BUG: "change" event is being generated too often

1 Answer 106 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Sergei
Top achievements
Rank 1
Sergei asked on 30 Jan 2012, 01:42 PM
"change" event is being generated when I click on already selected row.
Moreover the event is generated when I click in any place of detail row (in master-detail mode) if it contains a table with td's.

Also the event's handler arguments don't have any data about event context (i.e selected row), so I have to call "select()". That's not obvious. It's more naturally to get selected row in event handler. Also there's "current()" method which seems to be more suitable for getting currently selected row, but it returns undefined.

UPDATE:
When you're creating kendo.ui.Selectable inside Grid :

            that.selectable = new kendo.ui.Selectable(that.table, {
                filter: cell ? CELL_SELECTOR : ROW_SELECTOR,
                multiple: multi,
                change: function () {
                    that.trigger(CHANGE);
                }
            });

where ROW_SELECTOR = "tbody>tr:not(.k-grouping-row,.k-detail-row):visible"
you should specify "direct" selector:
ROW_SELECTOR = ">tbody>tr:not(.k-grouping-row,.k-detail-row):visible",

But unfortunetly it doesn't help when detail panel constains another grid.
Just take you sample http://demos.kendoui.com/web/grid/detailtemplate.html and add  "seletable: 'row'" into the first grid. And add handle for "change" event:
                    element.bind("change", function (e) {
                        var td = this.select();
                        console.log("selected: " + td);
                    });
then notice that it logs rows when you selected rows inside nested grid.

1 Answer, 1 is accepted

Sort by
0
Nikolay Rusev
Telerik team
answered on 01 Feb 2012, 10:58 AM
Hello Sergei,

"change" event is triggered whenever item is select. However the Grid does not track already selected items and this is the reason to trigger the event even if selecting same item.

Within the context of the event calling args.select() vs this.select() will be essentially the same.

current() is used only in the context of keyboard navigation in order to return currently highlighted item.

Regarding the issue with nested grid's we will do our best to fix it as soon as possible.

Regards,
Nikolay Rusev
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
Sergei
Top achievements
Rank 1
Answers by
Nikolay Rusev
Telerik team
Share this question
or