webismymind / editablegrid

EditableGrid is an open source Javascript library aimed at turning HTML tables into advanced editable components. It focuses on simplicity: only a few lines of code are required to get your first table up and running.
http://www.editablegrid.net
Other
795 stars 272 forks source link

buttons or other events inside cells #38

Closed pstaabp closed 11 years ago

pstaabp commented 11 years ago

I have a button inside of a cell, which I created a CellRenderer with "" code which works fine. I'd like to have it respond to a button click. I'd like the row to be deleted, but also have the rest of my code know that the row was deleted.

Any thoughts would be helpful.

In short, here's my code:

function DeleteCellRenderer(config) {
  this.init(config);
}

DeleteCellRenderer.prototype = new CellRenderer();
DeleteCellRenderer.prototype.render  = function(_cell,_value){
          $(_cell).html("<button class='btn btn-small'><i class='icon-trash'></i></button>")
              .on("click", {obj: this, cell: _cell, value: _value}, this.deleteRow); };

DeleteCellRenderer.prototype.deleteRow = function(evt) {
  var row =  evt.data.obj.editablegrid.getRowIndex($(evt.data.cell).parent().attr("id").split("_")[1]);

// I can remove the proper row here, but need to notify the rest of my program that the data was deleted.

              };
webismymind commented 11 years ago

Hi,

To remove a row, you should use : EditableGrid.prototype.remove = function(rowIndex). But, you're right, there no callback to notify that a row as been removed.

We will add this callback soon.

webismymind commented 11 years ago

I've just added the callback : rowRemoved().

pstaabp commented 11 years ago

Thanks. That sounds great. I think that editable grid has been a wonderful library for my project.

Peter

On Jul 5, 2013, at 4:56 AM, Webismymind notifications@github.com wrote:

I've just added the callback : rowRemoved().

— Reply to this email directly or view it on GitHub.