Skip to content

Commit

Permalink
table.plugin.CellEditing: prevent showing an editor in case editable …
Browse files Browse the repository at this point in the history
…is set to false for a given column #6144
  • Loading branch information
tobiu committed Dec 16, 2024
1 parent e0f6b92 commit a60ac94
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
2 changes: 1 addition & 1 deletion examples/table/cellEditing/MainContainer.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class MainContainer extends ConfigurationViewport {
columns: [
{dataField: 'firstname', text: 'Firstname'},
{dataField: 'lastname', text: 'Lastname'},
{dataField: 'githubId', text: 'Github Id'},
{dataField: 'githubId', text: 'Github Id', editable: false},
{dataField: 'country', text: 'Country'}
]
})
Expand Down
23 changes: 17 additions & 6 deletions src/table/plugin/CellEditing.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,22 @@ class CellEditing extends Plugin {
* @param {String} data.dataField
* @param {Object} data.record
* @param {Neo.table.View} data.view
* @returns {Promise<void>}
*/
async onCellDoubleClick({data, dataField, record, view}) {
let me = this,
cellId = view.getCellId(record, dataField),
cell = VdomUtil.find(view.vdom, cellId),
cellNode = cell.parentNode.cn[cell.index],
column = me.owner.headerToolbar.getColumn(dataField),
editor = me.editors[dataField];

if (me.mountedEditor) {
await me.unmountEditor(me.mountedEditor.record)
await me.unmountEditor()
}

if (column.editable === false) {
return
}

if (!editor) {
Expand Down Expand Up @@ -123,18 +129,23 @@ class CellEditing extends Plugin {
* @returns {Promise<void>}
*/
async onEditorKeyEscape(path, field) {
await this.unmountEditor(field.record)
await this.unmountEditor()
}

/**
* @param record
* @returns {Promise<void>}
*/
async unmountEditor(record) {
let tableView = this.owner.view,
async unmountEditor() {
if (!this.mountedEditor) {
return
}

let me = this,
record = me.mountedEditor.record,
tableView = me.owner.view,
rowIndex = tableView.store.indexOf(record);

this.mountedEditor = null;
me.mountedEditor = null;

tableView.vdom.cn[rowIndex] = tableView.createTableRow({record, rowIndex});
await tableView.promiseUpdate()
Expand Down

0 comments on commit a60ac94

Please sign in to comment.