Hi,
I am trying to programmatically select a row in a Grid depending on some dataItem value. My current approach is to loop through the rows in the DataBound event handler. So far I can find the row, but when I try to select it by using addClass("k-state-selectable") I get a "Object doesn't support this method or property" error.
Here is my code:
function gServices_DataBound(e) {
try {
var servicesGrid = $("#gServices").data("kendoGrid");
if (servicesGrid) {
var selServiceName = '@ViewData["SelServiceName"]';
if (selServiceName) {
// loop thorugh grid rows and select the service with that name
$("#gServices tr").each(function () {
var di = servicesGrid.data(this);
if (di.Name == selServiceName) {
// found the dataItem
// => select it
$(this).addClass("k-state-selected");
}
});
}
}
}
catch (ex) {
alert('gServices_DataBound: Exception: ' + ex.message);
}
}
Any ideas how I can loop through the set of rows and select the one I want programmatically?
Regards
Sven
I am trying to programmatically select a row in a Grid depending on some dataItem value. My current approach is to loop through the rows in the DataBound event handler. So far I can find the row, but when I try to select it by using addClass("k-state-selectable") I get a "Object doesn't support this method or property" error.
Here is my code:
function gServices_DataBound(e) {
try {
var servicesGrid = $("#gServices").data("kendoGrid");
if (servicesGrid) {
var selServiceName = '@ViewData["SelServiceName"]';
if (selServiceName) {
// loop thorugh grid rows and select the service with that name
$("#gServices tr").each(function () {
var di = servicesGrid.data(this);
if (di.Name == selServiceName) {
// found the dataItem
// => select it
$(this).addClass("k-state-selected");
}
});
}
}
}
catch (ex) {
alert('gServices_DataBound: Exception: ' + ex.message);
}
}
Any ideas how I can loop through the set of rows and select the one I want programmatically?
Regards
Sven