This is mix of datasource/grid question.
I have a [search] box with some criteria where user can enter some values and search, results gets displayed in grid and then I want to select the row. I am trying to get the [object] relevant to that row.
In following code, everything works upto selecting a row. I am not using the 'datasource' specification but instead using it within the search-click method. but how should I specify the schema/mode/id here so that when I select the row I can get row.data("id") value? As per following code, row.data("id") value is null.
Also, .data() method allows to store any object at the element level then why dont you store the whole object for the whole row.data()? and why you store only id?
$("#btnSearch").click(function() {
var searchobj = $("#searchForm").toDeepJson();
//console.log(searchobj);
myajax.WebService.SearchCustomers(searchobj, function(result) {
console.log(result.d);
gridCustomers.dataSource = new kendo.data.DataSource({
data: result.d,
schema: {
model: { id: "Name" }
}
});
gridCustomers.dataSource.read();
gridCustomers.refresh();
}); //searchcustomers
}); //btnSearch.click
}); //doc-ready
function onChange(arg) {
var row = this.select();
var id = row.data("id");
console.log(id);
}
I have a [search] box with some criteria where user can enter some values and search, results gets displayed in grid and then I want to select the row. I am trying to get the [object] relevant to that row.
In following code, everything works upto selecting a row. I am not using the 'datasource' specification but instead using it within the search-click method. but how should I specify the schema/mode/id here so that when I select the row I can get row.data("id") value? As per following code, row.data("id") value is null.
Also, .data() method allows to store any object at the element level then why dont you store the whole object for the whole row.data()? and why you store only id?
$("#btnSearch").click(function() {
var searchobj = $("#searchForm").toDeepJson();
//console.log(searchobj);
myajax.WebService.SearchCustomers(searchobj, function(result) {
console.log(result.d);
gridCustomers.dataSource = new kendo.data.DataSource({
data: result.d,
schema: {
model: { id: "Name" }
}
});
gridCustomers.dataSource.read();
gridCustomers.refresh();
}); //searchcustomers
}); //btnSearch.click
}); //doc-ready
function onChange(arg) {
var row = this.select();
var id = row.data("id");
console.log(id);
}