Skip to main content
12-Amethyst
September 4, 2015
Question

Making dynamically generated grid columns editable

  • September 4, 2015
  • 2 replies
  • 6337 views

A Grid is being populated with an Infotable that has dynamically generated fields. How does one make all columns of this grid editable? To be clear, the 'Configure Grid Columns' has no columns to show at design time.

2 replies

12-Amethyst
December 3, 2015

There is a hack. If you know what columns might be present, one could create a temporary DataShape capturing those, then use it for the configuration of the Grid and get rid of it once the configuration is done. The configuration is retained.

1-Visitor
September 22, 2016

There is only one solution for this limitation that I've been able to figure out.  Unfortunately, you won't be able to edit your grid rows directly in the grid , but I don't really think doing so is very elegant and it definitely seems to affect performance on grids with a lot of data and many editable columns. Also, the data driving your grid must reside in a data table.

Here's the solution:

Create a mashup that you will use as a pop-up window.  On the mashup, include all the fields you wish to be able to edit.  Include a "Save" button.  Configure the mashup to have one parameter for each field on the mashup. 

On your grid, configure the double-click event to call a service which takes the "Selected Row(s)" as input.  Since you know what your selected row looks like, from a data shape perspective, even though there isn't one specifically assigned to the grid, you'll be able to parse the infotable to extract the values of the fields you want to edit.  Be sure to include the ID--just don't display it on your pop-up if it's not needed. Return those values in a new infotable using a new DS of just those fields.  This new service now has an explicitly defined result data shape that you'll be able to use to map each one of the fields to a corresponding field on your mashup pop-up.   Use the service complete event to trigger a navigate widget which launches your pop-up. 

The pop-up will launch and all your fields will contain the corresponding data from the selected row in the grid.  Make whatever changes you need  to your data and then when a user clicks the the "Save" button, call a new service which takes all the values from your pop-up mashup and uses the ID field which you also passed in to do an update query on your data table.  When the user closes the pop-up, call the same service you initially called to populate your grid.  The grid will refresh with the updated data. 

22-Sapphire I
September 22, 2016

To power up this idea, you can use a repeater that dynamically shows the right mashup based on base type to create an editor for a dynamic table.