Browse Source

Added row index as parameter for the onEditableSave event (#4229)

* added rowindex as parameter for the onEditableSave event
Dustin U 6 years ago
parent
commit
a450f7b4d7

+ 1 - 1
site/docs/extensions/editable.md

@@ -69,7 +69,7 @@ Fired when all columns was initialized by `$().editable()` method.
 
 
 Fired when an editable cell is saved.
 Fired when an editable cell is saved.
 
 
-parameters: field, row, oldValue, $el
+parameters: field, row, rowIndex, oldValue, $el
 
 
 ### onEditableShown(editable-shown.bs.table)
 ### onEditableShown(editable-shown.bs.table)
 
 

+ 8 - 8
src/extensions/editable/bootstrap-table-editable.js

@@ -11,7 +11,7 @@
     onEditableInit () {
     onEditableInit () {
       return false
       return false
     },
     },
-    onEditableSave (field, row, oldValue, $el) {
+    onEditableSave (field, row, rowIndex, oldValue, $el) {
       return false
       return false
     },
     },
     onEditableShown (field, row, $el, editable) {
     onEditableShown (field, row, $el, editable) {
@@ -114,21 +114,21 @@
         $field.off('save').on('save', ({currentTarget}, {submitValue}) => {
         $field.off('save').on('save', ({currentTarget}, {submitValue}) => {
           const $this = $(currentTarget)
           const $this = $(currentTarget)
           const data = this.getData()
           const data = this.getData()
-          const index = $this.parents('tr[data-index]').data('index')
-          const row = data[index]
+          const rowIndex = $this.parents('tr[data-index]').data('index')
+          const row = data[rowIndex]
           const oldValue = row[column.field]
           const oldValue = row[column.field]
 
 
           $this.data('value', submitValue)
           $this.data('value', submitValue)
           row[column.field] = submitValue
           row[column.field] = submitValue
-          this.trigger('editable-save', column.field, row, oldValue, $this)
+          this.trigger('editable-save', column.field, row, rowIndex, oldValue, $this)
           this.initBody()
           this.initBody()
         })
         })
 
 
         $field.off('shown').on('shown', ({currentTarget}, editable) => {
         $field.off('shown').on('shown', ({currentTarget}, editable) => {
           const $this = $(currentTarget)
           const $this = $(currentTarget)
           const data = this.getData()
           const data = this.getData()
-          const index = $this.parents('tr[data-index]').data('index')
-          const row = data[index]
+          const rowIndex = $this.parents('tr[data-index]').data('index')
+          const row = data[rowIndex]
 
 
           this.trigger('editable-shown', column.field, row, $this, editable)
           this.trigger('editable-shown', column.field, row, $this, editable)
         })
         })
@@ -136,8 +136,8 @@
         $field.off('hidden').on('hidden', ({currentTarget}, reason) => {
         $field.off('hidden').on('hidden', ({currentTarget}, reason) => {
           const $this = $(currentTarget)
           const $this = $(currentTarget)
           const data = this.getData()
           const data = this.getData()
-          const index = $this.parents('tr[data-index]').data('index')
-          const row = data[index]
+          const rowIndex = $this.parents('tr[data-index]').data('index')
+          const row = data[rowIndex]
 
 
           this.trigger('editable-hidden', column.field, row, $this, reason)
           this.trigger('editable-hidden', column.field, row, $this, reason)
         })
         })