Get column values for rows selected in grid

4 Answers 8575 Views
Data Source
Richard
Top achievements
Rank 1
Richard asked on 29 Feb 2012, 08:03 PM
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.
TrentCioran
Top achievements
Rank 1
commented on 26 Mar 2012, 08:39 AM

Any resolution on this?

It would be very appreciated.
Sanjeev
Top achievements
Rank 1
commented on 28 Mar 2012, 10:47 PM

In Kendo Grid ,
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.
Any suggestions ?
Richard
Top achievements
Rank 1
commented on 29 Mar 2012, 05:28 AM

See this thread
Nickolay talks about the uid field and refers to the changes-and-backward-compatibility document.

4 Answers, 1 is accepted

Sort by
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.

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);

Regards,
Richard
TrentCioran
Top achievements
Rank 1
commented on 26 Mar 2012, 03:46 PM

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!
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 + ",";
         });
 }
Abhishek
Top achievements
Rank 1
commented on 05 Sep 2012, 05:05 AM

Thanks, it worked for me.
Graham
Top achievements
Rank 2
Iron
Iron
commented on 15 Dec 2016, 09:45 AM

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 + ",";
         });
 }
[/quote]
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);
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);
    }
Tags
Data Source
Asked by
Richard
Top achievements
Rank 1
Answers by
Richard
Top achievements
Rank 1
Troy Clemons
Top achievements
Rank 1
Manuel
Top achievements
Rank 1
Jono
Top achievements
Rank 1
Share this question
or