I'm displaying data in two different formats (grid with details and on a map based on location). I'm trying to make it so when you click on an object on the map then the corresponding row in the grid will get selected. I'm able to get the data of the object to use when clicking on it on the map, but I'm having trouble using it to select the row in the grid.
Here's the grid creation:
$("#grid").kendoGrid({
dataSource: {
data: myData
},
height: 400,
filterable: true,
sortable: true,
resizable: true,
pageable: false,
selectable: true,
schema: {
model: {
id: "MyId"
}
},
columns: [
{
field: "MyId",
hidden:true
},
{
field: "Name",
title: "Name",
filterable: false, width: 100
},
{
field: "Foo",
title: "Foo", width: 160
},
{
field: "Bar",
title: "Bar", width: 110
}
]
});
And here's the shapeClick event for the map:
var el = $("#grid"),
grid = el.data("kendoGrid"),
row = el.find("tbody>tr[data-id="+e.shape.dataItem.MyId+"]");
grid.select(row);
Using alerts I'm able to verify that I've got MyId correctly, and el, grid, and row are all objects, so I would assume it's getting the right things, but it's not selecting the row on the grid like it should be.
Anyone have any ideas?
The shapeClick event handler implementation looks OK. Did you checked the console for any JavaScript errors that might give us a clue what is going wrong? Did you checked if the row element is found?
var
el = $(
"#grid"
),
grid = el.data(
"kendoGrid"
),
row = el.find(
"tbody>tr[data-id="
+e.shape.dataItem.MyId+
"]"
);
alert(row.length);
//check if the row is found
grid.select(row);
Regards,
Alexander Valchev
Telerik