This question is locked. New answers and comments are not allowed.
I can't seem to find a consistent way to get information from the currently selected row. The code I see in the demo, and being used here in the forums is:
But that simply doesn't fly when you're using a groupable grid. As soon as you group any columns, the indexes start moving around. I'd much rather see something like:
Any suggestions?
-Jeff
var id = e.row.cells[#].innerHTML; |
But that simply doesn't fly when you're using a groupable grid. As soon as you group any columns, the indexes start moving around. I'd much rather see something like:
var id = e.dataItem.ID; |
Any suggestions?
-Jeff
8 Answers, 1 is accepted
0
Hello Jeff Sheldon,
Since the dataItem is currently available only in the rowDataBound event I can suggest the following:
var id = e.row.cells[grid.groups.length + cellIndex].innerHTML;
If you are using editing you can use the following JavaScript function:
var dataItem = grid.dataItem($(e.row));
We will make it always available (not just when editing is enabled) in the next release.
Regards,
Atanas Korchev
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.
Since the dataItem is currently available only in the rowDataBound event I can suggest the following:
var id = e.row.cells[grid.groups.length + cellIndex].innerHTML;
If you are using editing you can use the following JavaScript function:
var dataItem = grid.dataItem($(e.row));
We will make it always available (not just when editing is enabled) in the next release.
Regards,
Atanas Korchev
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.
0
Rafael
Top achievements
Rank 1
answered on 17 Sep 2010, 10:23 AM
Atanas, could you please to help with code to color by condition a row in nested view (master/detail grid) ?
I got undefined for e.row
This is a bound function for nested grid
I got undefined for e.row
This is a bound function for nested grid
function project_OnDataBound(e) {
var grid = $(this).data('tGrid');
$.each(grid.data, function (i, val) {
var probability = grid.data[i].Probability;
if (probability <= 50) {
e.row.style.color = "red";
}
if (probability > 50 && probability <= 80) {
e.row.style.color = "yellow";
}
if (probability > 80 && probability <= 99) {
e.row.style.color = "lightgreen";
}
});
}
0
Diiimo
Top achievements
Rank 1
answered on 29 Sep 2010, 07:13 AM
Hello,
is the dataItem now available? please, could you provide a sample?
Regards,
Timo
0
Hi Timo,
Atanas Korchev
the Telerik team
DataItem is not available in OnRowSelect and probably will never be available. You can use the dataItem function to retrieve the dataItem associated with a particular row at any moment:
function onRowSelect(e) {
var grid = $(this).data('tGrid');
var dataItem = grid.dataItem(e.row);
}
Atanas Korchev
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
0
Diiimo
Top achievements
Rank 1
answered on 29 Sep 2010, 08:38 AM
Hello,
it works for AjaxBinding. Is there a way to do this with ServerBinding?
Regards,
Timo
0
Hello Timo,
Atanas Korchev
the Telerik team
JavaScript DataItem is not available in server binding. You can use a hidden column instead.
Regards,Atanas Korchev
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
0
Rafael
Top achievements
Rank 1
answered on 29 Sep 2010, 09:33 AM
hi Timo,
see sample in my previous post
I used Ajax binding, but e.row is still undefined
see sample in my previous post
I used Ajax binding, but e.row is still undefined
0
Hello Rafael,
Atanas Korchev
the Telerik team
Perhaps you are using the wrong event. You should use OnRowDataBound instead of OnDataBound.
I am locking this forum thread as it digressed from the original question.
Atanas Korchev
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