1

This is based on slickgrid example 1. I would like to have the button inside slickgrid call another instance of slickgrid in another modal. At the moment i am unable to interact with the button inside the grid aside from getting it to display. Here is my fiddle JSfiddle

 {id: "newgrid", name: "newgrid", field: "newgrid", width: 80, sortable: true, formatter:reportFormatter}

function reportFormatter(row, cell, value, columnDef, dataContext) {
  return "<button class='show-report'>show</button>";
}

Ive tried to use

 myGrid.onClick.subscribe(function(e,args) {
 if ($(e.target).hasClass('show-report')) {
    alert("hello");
 }
});
Leonardo Wildt
  • 2,529
  • 5
  • 27
  • 56

1 Answers1

2

Use the onClick subscribe like this instead (and also right after it has been instantiated)

grid.onClick.subscribe(function(e,args) {
 if ($(e.target).hasClass('show-report')) {
    alert("hello");
 }
});

Since the grid instance is like this

grid = new Slick.Grid("#myGrid", data, columns, options);

Dhiraj
  • 33,140
  • 10
  • 61
  • 78
  • That worked perfectly, any ideas on how i could link a modal to that button? Much like the one that initiated the grid to begin with? – Leonardo Wildt Apr 09 '15 at 14:51
  • 1
    that seems to be a bigger question itself. For starters, try this http://stackoverflow.com/questions/13183630/how-to-open-a-bootstrap-modal-window-using-jquery – Dhiraj Apr 09 '15 at 15:10