Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Slickgrid, how to get the grid item on click event?

Tags:

slickgrid

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?

like image 206
user469652 Avatar asked Dec 03 '11 02:12

user469652


3 Answers

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

  // or dataView.getItem(args.row);
});
like image 165
Tin Avatar answered Oct 26 '22 08:10

Tin


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

         });
like image 42
chrisfauerbach Avatar answered Oct 26 '22 08:10

chrisfauerbach


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;
});
like image 35
alienfromouterspace Avatar answered Oct 26 '22 07:10

alienfromouterspace