7
grid.onClick.subscribe(function(e) {
    var cell = grid.getCellFromEvent(e),
        row = cell.row;

    // var item = dataView.rows[row];

});

I used to use dataView.rows to access the item inside a grid, and this seems not working in the latest version any more, how shall we update the code?

user469652
  • 48,855
  • 59
  • 128
  • 165

3 Answers3

15
grid.onClick.subscribe(function(e, args) {
  var item = args.item;

  // or dataView.getItem(args.row);
});
Blowsie
  • 40,239
  • 15
  • 88
  • 108
Tin
  • 9,082
  • 2
  • 34
  • 32
7

This gets me to the object itself:

grid.onClick.subscribe(function(e, args) {
           console.log('clicked: ');
           console.log(args);
           var item = args.grid.getData()[args.row];
           console.log(item);

         });
  • 1
    I like this the best. Or rather args.grid.getDataItem(args.row); Is it possible to update the dataView through args in any way? I don't have access to any global var for dataView within this scope. – Kirby Jun 19 '15 at 12:37
5

This is quite an old thread, still I felt to update it since args no longer has 'item' in it.

Now it is:

grid.onClick.subscribe(function(e, args) {
    var cell = args.cell,
    row = args.row;
});