A way to clear a Data Grid's `item_template` field

I.e., this field:
image

Currently, after cloning (duplicating) a Form that contains a Data Grid, it’s very awkward to create a new item template for the new Form’s Data Grid.

If you were building a Form from scratch, then double-clicking in the Grid’s first row would create an empty template, a Form whose outermost container is a DataRowPanel. But with a cloned Data Grid, that doesn’t work, because the item_template field is already filled. Double-clicking it “merely” drills down into the existing template.

You can create a new Form, for use as an item template, but it will use a different type of outer container, and so it will not play well with the Data Grid. I had to hack the new item template’s .yaml file and manually change the outermost container, to match one from another item template.

But that only works because I’m using Anvil’s Git integration, to get a local copy of the .yaml file, for local editing. For a “regular” developer, using only the IDE, there’s no way to hack it.

Why bother to clone an existing Form, if such obstacles exist? Easy: all the other things on the Form, including code, that would otherwise have to be manually copied or re-created.

1 Like

This is a related FR: Improvements to form duplicate command

1 Like

Agree completely. This is what “package” forms were meant for, from their beginning: to improve modularity and encapsulation.

Having a “clear” button for the item_template field – or even if the field just responded to the delete key – is not as comprehensive a solution. It only removes a single obstacle for the IDE user. But as a much smaller change, it might be quicker to implement. And certainly easier to test!

1 Like