This is a migrated thread and some comments may be shown as answers.
Bug when using onRowDataBound and Grouping
1 Answer 31 Views
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Jason Walker
Top achievements
Rank 1
Jason Walker asked on 22 Mar 2010, 07:45 PM
I'm implementing client-side highlighting of a row by adding a "Selected" property to the objects I bind to, and then implementing onRowDataBound like so:

function setRowSelected(item) { 
    if(item.dataItem.Selected) 
        $(item.row).addClass('t-state-selected'); 

This works as expected, except when I have grouping enabled.  In this case, item.row seems to point to the wrong row - the grouping rows mess things up.

In the attached image, the 4th row should be highlighted, but the third row is actually highlighted.

1 Answer, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 23 Mar 2010, 10:49 AM
Hello Jason Walker,

I confirm the aforementioned issue was a bug. It is fixed and will be included in next release of the Telerik Components for ASP.NET MVC.

You can fixed it by your own as you find this code part of BindTo method placed in the telerik.grid.js:
...
            this.$tbody.html(html.string());
 
            if (this.onRowDataBound) {
                var rows = this.$tbody[0].rows;
                for (var i = 0, l = this.data.length; i < l; i++)
                    $t.trigger(this.element, 'rowDataBound', { row: rows[i], dataItem: this.data[i] });
            }
...

 with this code snippet:
this.$tbody.html(html.string());
 
if (this.onRowDataBound) {
 
    var rows = jQuery.grep(this.$tbody[0].rows, function(row) {
        return !$(row).hasClass('t-grouping-row')
    });
 
    for (var i = 0, l = this.data.length; i < l; i++)
        $t.trigger(this.element, 'rowDataBound', { row: rows[i], dataItem: this.data[i] });
}

Greetings,
Georgi Krustev
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
Grid
Asked by
Jason Walker
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
Share this question
or