Skip to content

Commit 29ed503

Browse files
committed
selection.grid.BaseModel: getRecordId() #6667
1 parent e3f7a4b commit 29ed503

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

src/selection/grid/BaseModel.mjs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,30 @@ class BaseModel extends Model {
2323
return this.view.parent.columns.items.map(column => column.dataField)
2424
}
2525

26+
/**
27+
* Get the record for a given event path
28+
* @param {Object[]} path
29+
* @param {String} nodeId
30+
* @returns {Number|String|null}
31+
*/
32+
getRecordId(path, nodeId) {
33+
let node, recordId;
34+
35+
for (node of path) {
36+
if (node.id === nodeId) {
37+
recordId = node.data.recordId;
38+
39+
if (this.view.store.getKeyType()?.includes('int')) {
40+
recordId = parseInt(recordId)
41+
}
42+
43+
return recordId
44+
}
45+
}
46+
47+
return null
48+
}
49+
2650
/**
2751
* Checks if an event path contains a grid cell editor
2852
* @param {Object} data

0 commit comments

Comments
 (0)