No announcement yet.
  • Filter
  • Time
Clear All
new posts

    Change field's edit type after record is in edit mode


    I've searched the docs and forum and haven't found a solution yet - so thought it was time to ask for direction and see if anybody had solved this scenario before.

    We have a ListGrid that is editible. We want the users to edit/validate entire records (as in, not edit by cell). While editing a record, there is a field with some choices presented as a "select" - and based on what they choose for that field, another field in the record should either present a standard text input, or a select control with options.

    So, essentially we're looking for the best way to dynamically change the edit type for a field for a record that is already being edited.

    Looking at the method "getEditType" - that works for when editing the record starts, as we can look at the current value of the field that determines what editor should be presented, but where we're getting stuck is how to handle the change after editing has started and the field's editor has already been determined.

    Does anyone have any thoughts on how best to change an editor type for a field after the record has entered edit mode and the edit fields have already been created?



    Use refreshRow().


      Calling refreshRow() doesn't seem to have any impact on the editors, and I'm not seeing it trigger a new call to "getEditorType".

      Without exiting edit mode on a row, I want to update the form item type for a field in the row, based on a change that the user makes in another field on that row... all before committing the edits for the row.

      Meaning - while the user is editing a row, they select an option from the drop down for Field1, and then based on what option they selected, Field2 changes to either a "SelectItem" or a regular "TextItem". As in, I need to dynamically change the editor being offered for a given field while editing a row based on a change the user makes to a different field within that same row.

      Edit: One approach that I'm considering is to subclass my own formitem type, and include with that the ability morph between providing text input and select input. Then, I can have the change take place within the form item itself, versus having the grid have to worry about it.
      Last edited by; 5 May 2022, 13:55.


        I did solve this and wanted to share in case it helps anybody else down the road.

        Instead of trying to get the grid to swap out different form item types during editing, I created my own form item type based on the "CanvasItem" that has an embedded DynamicForm with multiple fields, and then some custom methods that allow an outside caller to tell it which field to show, while hiding the rest. Then, from within a row in the ListGrid that is being edited, I can get a reference to the form item by calling "getEditFormItem" and manipulate it from there to dynamically change how my custom form item is presenting itself.

        Once I went down that path, turned out to be pretty simple and works really well.


          Yup, we've used that approach too. But just to clarify: both approaches do work, so it's more a matter of style.

          One advantage of the CanvasItem approach is that, if the same editing also happens outside the grid (eg in a form), you can use the same item there.