I'm quite new to Kendo UI and would appreciate if someone could give an advice. I need to get a value of specific column when my grid row is selected. Till now I can get the values of all columns of selected row:
$("#grid").kendoGrid({
...
change:onChange,
columns: [{
field: "Number",
title: 'Number',
}, {
field: "Title",
title: "Title",
}]
});
onChange function:
function onChange(arg) {
var selected = $.map(this.select(), function (item) {
return $(item).text();
});
alert(selected);
}
I need to take the selected value of Number
column. Something like $(item[name='Number']).text();
I know I could parse the string but I guess there is another way.
Thanks a lot
I'm quite new to Kendo UI and would appreciate if someone could give an advice. I need to get a value of specific column when my grid row is selected. Till now I can get the values of all columns of selected row:
$("#grid").kendoGrid({
...
change:onChange,
columns: [{
field: "Number",
title: 'Number',
}, {
field: "Title",
title: "Title",
}]
});
onChange function:
function onChange(arg) {
var selected = $.map(this.select(), function (item) {
return $(item).text();
});
alert(selected);
}
I need to take the selected value of Number
column. Something like $(item[name='Number']).text();
I know I could parse the string but I guess there is another way.
Thanks a lot
Share Improve this question asked Jul 29, 2014 at 11:59 GyuzalGyuzal 1,59111 gold badges54 silver badges105 bronze badges2 Answers
Reset to default 5You should be using the dataItem
method of the Kendo UI Grid to retrieve the actual data item of the row you selected - reference. Then, you can retrieve the value you need by property name.
function onChange(e) {
var selected = this.select()[0],
item = this.dataItem(selected);
alert(item.Number);
}
if you have multiple selection and want to collect first column of all selected row. use following code
var allSelected = "";
var selectedRows = this.select();
for (i = 0; i < selectedRows.length ; i++) {
allSelected = allSelected + ", " + this.dataItem(selectedRows[i]).task_number;
}