cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - You can Bookmark boards, posts or articles that you'd like to access again easily! X

Making dynamically generated grid columns editable

VinayVaidya
11-Garnet

Making dynamically generated grid columns editable

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.

13 REPLIES 13

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.

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. 

PaiChung
22-Sapphire I
(To:wposner-2)

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.

Hey a bit late to the party, but in any case can you elaborate more on how to create the service that will be displayed in the pop-up mashup

hi,

what type of service is used, you told  "On your grid, configure the double-click event to call a service which takes the "Selected Row(s)" as input."


I configured my grid to open a pop-up in that I create fields and I used "Get Data Table entries" as service but I am unable to load the values into that mashup...

could you explain clearly... what type of service is used..?

PaiChung
22-Sapphire I
(To:mnalla)

Grid Double Click -> Navigation Widget to open Pop Up mashup -> Pop Up mashup must have Mashup Parameter

Pass Grid Data Source Selected Row KEY to Navigation Widget map to Mashup parameter

In Pop Up use Mashup parameter to do GetDataTableEntryByKey

Display in Editable boxes

Bind Editable boxes to AddOrUpdateDataTableEntry

Button to execute AddOrUpdateDataTableEntry service

AddOrUpdateDataTableEntry Service Invoke Completed to Close Mashup if Pop up

Navigate Widget on Popup Close to GetDataTableEntries to refresh content

mnalla
7-Bedrock
(To:PaiChung)

Hi pai Chung,

ThankYou for the reply. Should I have to create a grid widget again in the Pop-mashup...??

I dis not get what is Mashup Parameter..??

Could you please elaborate your answer..??

PaiChung
22-Sapphire I
(To:mnalla)

The help isn't super great

http://support.ptc.com/help/thingworx_hc/thingworx_7_hc/#page/ThingWorx%2FThingWorxHelpCenterDITAFiles%2FMashupBuilder%2FMashups%2FMashupParameters.html

you can do some searches here on the community for Mashup parameter as well.

but in that pop up mashup you are bringing back one single record to edit, I would not use a grid, but individual widgets per value to be edited.

mnalla
7-Bedrock
(To:PaiChung)

Hi Pai Chung,

ThankYou for the reply, I implemented what you told in your reply such as adding mashup parameter, AddorUpdateDataTable entry etc But Still I am unable to get the data into the mashup fields..?

can you suggest anything?

I will appreciate your help.

regards,

madhu

PaiChung
22-Sapphire I
(To:mnalla)

can you post some screenshots of how you have defined your mashups?

mnalla
7-Bedrock
(To:PaiChung)

hi Paichung,

1.PNG2.PNG

3.PNG

"Pass Grid Data Source Selected Row KEY to Navigation Widget map to Mashup parameter"

for this as shown in 3rd image i used parent mashup "GetDataTableEntries" Service and in that key to navigate widget to mashup parameter

PaiChung
22-Sapphire I
(To:mnalla)

Not sure what isn't displaying for you but the wiring all looks good.

mnalla
7-Bedrock
(To:PaiChung)

Hi Pai Chung,

I am able to execute it. I rectified my mistake. ThankYou for the help.

regards,

madhu

Top Tags