Skip to content

Commit

Permalink
New: keys.editorOptions callback which can be used to modify how th…
Browse files Browse the repository at this point in the history
…e `e-api inline()` method is called

https://datatables.net/forums/discussion/68861
  • Loading branch information
AllanJard committed Jul 15, 2021
1 parent c726374 commit 0795284
Showing 1 changed file with 26 additions and 2 deletions.
28 changes: 26 additions & 2 deletions js/dataTables.keyTable.js
Expand Up @@ -471,8 +471,10 @@ $.extend( KeyTable.prototype, {
if ( editor ) {
// Got Editor - need to activate inline editing,
// set the value and submit
var options = that._inlineOptions(focused.cell.index());

editor
.inline( focused.cell.index() )
.inline(options.cell, options.field, options.options)
.set( editor.displayed()[0], pastedText )
.submit();
}
Expand Down Expand Up @@ -562,6 +564,8 @@ $.extend( KeyTable.prototype, {
}

var editInline = function () {
var options = that._inlineOptions(editCell.index());

editor
.one( 'open'+namespace, function () {
// Remove cancel open
Expand Down Expand Up @@ -616,7 +620,7 @@ $.extend( KeyTable.prototype, {
// might be that the open event handler isn't needed
editor.off( namespace );
} )
.inline( editCell.index() );
.inline(options.cell, options.field, options.options);
};

// Editor 1.7 listens for `return` on keyup, so if return is the trigger
Expand All @@ -635,6 +639,20 @@ $.extend( KeyTable.prototype, {
},


_inlineOptions: function (cellIdx)
{
if (this.c.editorOptions) {
return this.c.editorOptions(cellIdx);
}

return {
cell: cellIdx,
field: undefined,
options: undefined
};
},


/**
* Emit an event on the DataTable for listeners
*
Expand Down Expand Up @@ -1188,6 +1206,12 @@ KeyTable.defaults = {
*/
editOnFocus: false,

/**
* Options to pass to Editor's inline method
* @type {function}
*/
editorOptions: null,

/**
* Select a cell to automatically select on start up. `null` for no
* automatic selection
Expand Down

0 comments on commit 0795284

Please sign in to comment.