Search code examples
javascriptjqueryslickgrid

clear cell based on another cell in different column after edit in SlickGrid


I created those two columns.

 var columns = [

    {id: "Fclass", name: "Class", field: "Fclass", minWidth:100,width:150, options:["10000","Dallas","10002","10003","10004","10005","10006","10007","10008","10009","10010"], editor: Slick.Editors.Auto},
    {id: "subclass", name: "Subclass", field: "subclass", minWidth:100,width:150, dependency:"Fclass", editor: Slick.Editors.Auto}

  ];

The column with field named "subclass" depends on the column with field "Fclass". So what happens is, in onBeforeEditCell function, the cell in "subclass" is populated according to the value selected in the cell in "Fclass" column. So far everything goes fine.

However, I'm trying to figure if cell in "Fclass" is cleared after edit, how to clear the cell in "subclass" as well. That's why I'm looking for a function like "onAfterEditCell" but I believe there is no such function in SlickGrid API.

Note: I don't want to touch "applyValue" function in Slick.Editors.js file because of maintaining consistency. However, if you say there is no way around other than editing applyValue function, please provide some information.

Any suggestions would be gratefully appreciated. Thank you


Solution

  • You can use the onBeforeCellEditorDestroy event callback to catch this. This event is triggered when the cell you are editing loses focus. This actually destroys the editor associated with the cell.