Suppose I have know the rows selected in a grid
grid = $('#myTable').data('kendoGrid');
rows = grid.select();
and I know that I want the values from field 'abc'.
Without any apriori knowledge of the model how would I do something per this pseudo code:
for (row in rows) {
i++;
abcs[i] = row.valueof (field-abc)
}
The abcs would be used later as data of a transport.
grid = $('#myTable').data('kendoGrid');
rows = grid.select();
and I know that I want the values from field 'abc'.
Without any apriori knowledge of the model how would I do something per this pseudo code:
for (row in rows) {
i++;
abcs[i] = row.valueof (field-abc)
}
The abcs would be used later as data of a transport.
4 Answers, 1 is accepted
0
Richard
Top achievements
Rank 1
answered on 26 Mar 2012, 03:43 PM
Manuel:
I'm not sure if this is the 'approved way', but it seems to work.
Regards,
Richard
I'm not sure if this is the 'approved way', but it seems to work.
var
gridDataArray = $(
'#myGrid'
).data(
'kendoGrid'
)._data;
var
columnDataVector = [];
var
columnName =
'aFieldInModel'
;
for
(
var
index=0; index<gridDataArray.length;index++) {
columnDataVector[index] = gridDataArray[index][columnName];
};
alert(columnDataVector);
Richard
TrentCioran
commented on 26 Mar 2012, 03:46 PM
Top achievements
Rank 1
Yeah.. that is the way I am currently accessing to the data, but as you, I'm not sure it is the correct way of doing it.
Thanks!
Thanks!
0
Troy Clemons
Top achievements
Rank 1
answered on 29 Mar 2012, 12:45 PM
this is how i am getting values from a grid by selection, maybe this will help you.
change:
function
()
var
text = 0.00;
var
UsedBooks =
""
;
var
grid = $(
"#CusGrid"
).data(
"kendoGrid"
);
grid.select().each(
function
() {
var
dataItem = grid.dataItem($(
this
));
text += Number(dataItem.RevHandeled);
UsedBooks += dataItem.BookYear +
","
;
});
}
Graham
commented on 15 Dec 2016, 09:45 AM
Top achievements
Rank 2
Iron
Iron
Thanks Troy - this is perfect!
[quote]Troy Clemons said:this is how i am getting values from a grid by selection, maybe this will help you.
change:
function
()
var
text = 0.00;
var
UsedBooks =
""
;
var
grid = $(
"#CusGrid"
).data(
"kendoGrid"
);
grid.select().each(
function
() {
var
dataItem = grid.dataItem($(
this
));
text += Number(dataItem.RevHandeled);
UsedBooks += dataItem.BookYear +
","
;
});
}
0
Manuel
Top achievements
Rank 1
answered on 07 Sep 2012, 04:24 PM
hi !
if first column is the key, then :
var grid = $("#grid").data("kendoGrid");
var row = grid.select() ;
var uid = row.data("uid");
var tr_first=$('[data-uid="'+uid+'"] td:first').text();
alert(tr_first);
if first column is the key, then :
var grid = $("#grid").data("kendoGrid");
var row = grid.select() ;
var uid = row.data("uid");
var tr_first=$('[data-uid="'+uid+'"] td:first').text();
alert(tr_first);
0
Jono
Top achievements
Rank 1
answered on 07 May 2013, 01:07 AM
This might be a little late but for those wanting to select a specific column for a selected row. This works well for me.
function
onChange(arg) {
alert(
"coloumnName "
+
this
.dataItem(
this
.select()).coloumnName);
}
It would be very appreciated.
On selecting a row, it seems the new version broke for getting the data selected column
change: function () {
var Row = this.select();
alert(Row.data("id"));
}
Note: It was working in earlier release.
Nickolay talks about the uid field and refers to the changes-and-backward-compatibility document.