Hello
I am trying to find a way to set the Grid data-uid to the primary key in my datasource so that i can find the row programmatically.
I do not require users to select rows in the grid, it needs to be done via script.
I have looked though the grid datasource documentation and there seems to be no way to set it.
Thanks
I am trying to find a way to set the Grid data-uid to the primary key in my datasource so that i can find the row programmatically.
I do not require users to select rows in the grid, it needs to be done via script.
I have looked though the grid datasource documentation and there seems to be no way to set it.
Thanks
So, it can be something like:
var
dataSource =
new
kendo.data.DataSource({
data : [
{
"ID"
: 2,
"Name"
:
"Jane"
},
{
"ID"
: 3,
"Name"
:
"Sam"
},
{
"ID"
: 4,
"Name"
:
"Charles"
},
{
"ID"
: 1,
"Name"
:
"John"
},
{
"ID"
: 5,
"Name"
:
"Paul"
},
{
"ID"
: 6,
"Name"
:
"Josh"
},
{
"ID"
: 7,
"Name"
:
"Daniel"
}
],
schema : {
model: {
id:
"ID"
}
},
pageSize: 8
});
var
grid = $(
"#kendogrid"
).kendoGrid({
dataSource: dataSource,
selectable:
true
,
columns : [
{ field:
"ID"
},
{ field:
"uid"
},
{ field:
"Name"
}
]
}).data(
"kendoGrid"
);
function selectElementGivenItsId
(id) {
var
item = grid.dataSource.get(id);
var
tr = $(
"[data-uid='"
+ item.uid +
"']"
, grid.tbody);
grid.select(tr);
});
Any Answer to this?