Dynamic Editor Configuration Request #1692
-
Clear and concise description of the problemCurrently, in Slickgrid-Universal, the column definition allows setting a static Editor for each column (e.g., Editor.text or Editor.singleSelect). However, I have a use case where I need the Editor to change dynamically based on the data in each row. For example: In the first row, the first column should use a text input editor; Suggested solutionI would like to have a way to define the Editor dynamically, depending on the row's data. Ideally, it could work similarly to a callback function, where I can return the appropriate editor for each row. For example: {
id: 'exampleColumn',
field: 'exampleField',
editor: (item) => {
if (item.type === 'text') {
return Editor.text;
} else if (item.type === 'select') {
return Editor.singleSelect;
}
return null;
}
} Current Behavior: Right now, it is only possible to define a static Editor for the entire column, and it cannot be changed dynamically based on the row's data. Use Case: In my application, each row contains different types of data that require different input methods. For example: Some rows contain text data that should be edited with a text input; AlternativeNo response Additional contextNo response Validations
|
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 4 replies
-
You can try to change the editor via the |
Beta Was this translation helpful? Give feedback.
-
you could perhaps also create a new composite editor which wraps both the original ones and has means to change its active appearance. if its exactly two types (input, select) this custom editor would be my goto solution due to more control |
Beta Was this translation helpful? Give feedback.
-
Thanks for the suggestion! I think it's a great idea to have a composite editor to switch between input and select. However, I'm a bit unsure about how to implement it. Could you provide some guidance or an example of how the code would look? It would really help to see the structure and approach. Thanks in advance! |
Beta Was this translation helpful? Give feedback.
-
I think you should first try with If you want to go with a Custom Editor then simply look at the Custom Editor Documentation, I tried to document as much as possible because searching documentation is easy and is better than answering by memory which is not always good (docs are better in so many ways). I converted the issue to a Discussion because like I tagged earlier, it's not an issue but rather a Question of How to do such thing |
Beta Was this translation helpful? Give feedback.
it doesn't work because internally because Slickgrid-Universal, or other any other ports like Slickgrid-React, now keeps 2 references to the Editor as shown below
slickgrid-universal/packages/vanilla-bundle/src/components/slick-vanilla-grid-bundle.ts
Lines 1525 to 1531 in 79d1995
So you need to update both references to make it work,
editor.model
andeditorClass
c…