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

modelChange callback should be called after setValueAt()? #7

Closed jasvazquez closed 13 years ago

jasvazquez commented 13 years ago

Just wondering why actually modelChange is not triggered when we use setValueAt() method :)

webismymind commented 13 years ago

The modelChanged callback is called when the model has been updated out of your control, i.e. when the table has been edited by the user.

If you call SetValueAt, your are the initiator of the change, and it is up to you to do whatever is needed. Calling modelChanged may not always be the thing to do. But if you want to call modelChanged, it can be done like this:

var previousValue = editablegrid.setValueAt(rowIndex, columnIndex, newValue);
editablegrid.modelChanged(rowIndex, columnIndex, previousValue, newValue, editablegrid.getRow(rowIndex));
jasvazquez commented 13 years ago

Thanks for the explanation.

ghost commented 12 years ago

Thanks, it works well :)