Get column values for rows selected in grid

10 posts, 0 answers
  1. RichardAD
    RichardAD avatar
    105 posts
    Member since:
    Feb 2012

    Posted 29 Feb 2012 Link to this post

    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.
  2. TrentCioran
    TrentCioran avatar
    13 posts
    Member since:
    Aug 2012

    Posted 26 Mar 2012 Link to this post

    Any resolution on this?

    It would be very appreciated.
  3. Kendo UI is VS 2017 Ready
  4. RichardAD
    RichardAD avatar
    105 posts
    Member since:
    Feb 2012

    Posted 26 Mar 2012 Link to this post

    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
  5. TrentCioran
    TrentCioran avatar
    13 posts
    Member since:
    Aug 2012

    Posted 26 Mar 2012 Link to this post

    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!
  6. Sanjeev
    Sanjeev avatar
    1 posts
    Member since:
    Apr 2011

    Posted 28 Mar 2012 Link to this post

    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 ?
  7. RichardAD
    RichardAD avatar
    105 posts
    Member since:
    Feb 2012

    Posted 29 Mar 2012 Link to this post

    See this thread
    Nickolay talks about the uid field and refers to the changes-and-backward-compatibility document.
  8. Troy Clemons
    Troy Clemons avatar
    69 posts
    Member since:
    Apr 2010

    Posted 29 Mar 2012 Link to this post

    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 + ",";
             });
     }
  9. Abhishek
    Abhishek avatar
    7 posts
    Member since:
    Jul 2012

    Posted 05 Sep 2012 Link to this post

    Thanks, it worked for me.
  10. Manuel
    Manuel avatar
    1 posts
    Member since:
    Jan 2012

    Posted 07 Sep 2012 Link to this post

    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);
  11. Jono
    Jono avatar
    2 posts
    Member since:
    Aug 2012

    Posted 06 May 2013 Link to this post

    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);
        }
Back to Top
Kendo UI is VS 2017 Ready