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

Community Tip - New to the community? Learn how to post a question and get help from PTC and industry experts! X

Passing event from collection widget cell to collection widget

khayes1
13-Aquamarine

Passing event from collection widget cell to collection widget

Hi,

wondering if there is a way to pass a button click in a collection widget cell mashup to the collection widget refresh.

 

I have a list of items displayed in a collection widget. There is a 'delete item' button in each item's cell mashup. I'm looking for a way to pass the click event on the button back to the collection widget itself so that it can redraw itself with the new list (minus the deleted item).

 

Currently I manage this by having the delete button set a boolean session parameter to true. In the main mashup I have a timer running (every second) which checks the state of the boolean & if true redraws the collection widget (list). It works, but seems clunky, so would prefer a way to pass the button click in the cell back to the collection widget without having to use a timer. I did try tying a validator to the session parameter, but it didn't appear to trigger when the session boolean changed.

 

TIA

K

1 ACCEPTED SOLUTION

Accepted Solutions

No need to use that. In the Cell Mashup define an Expression which outputs new Date(), guaranteed to always change.

Create a new Session variable named CollectionRefresh, type DateTime. Make the Delete button call the Evaluate service of the Expression. In the host mashup, the CollectionRefresh Session variable will have a CollectionRefreshChanged event -> bind that to the service that refreshes the infotable.

 

I believe there might be an alternative way with the collection events that are generated from the input global parameters, just didn't try that in while.

 

Note:In reality you just need to setup the Session variable to "Always" and use any result in that expression.

View solution in original post

3 REPLIES 3

No need to use that. In the Cell Mashup define an Expression which outputs new Date(), guaranteed to always change.

Create a new Session variable named CollectionRefresh, type DateTime. Make the Delete button call the Evaluate service of the Expression. In the host mashup, the CollectionRefresh Session variable will have a CollectionRefreshChanged event -> bind that to the service that refreshes the infotable.

 

I believe there might be an alternative way with the collection events that are generated from the input global parameters, just didn't try that in while.

 

Note:In reality you just need to setup the Session variable to "Always" and use any result in that expression.

Since session variables are global they are harder to manage. Is there a way to achieve this without session variables?

Yes, you can use the globalPropertyBinding property of the collection widget. In there, define a DeletedPropertyId property of whatever type your id is. It will look something like this.

{

    "DeletedPropertyId": "STRING"

}

 

Inside your cell mashup, define a mashup parameter with the same name and type as the one you defined in your global properties. Also in your cell mashup, create an expression which returns the propertyId and have it evaluate only when you click the delete button. Bind that expression output to your "DeletedPropertyId" mashup parameter.

 

Inside you containing mashup(where you have the collection widget) you will see that the "DeletedPropertyId" is available in the collection widget, just like any other bindable property. Make an expression there that takes "DeletedPropertyId" from the collection as input and just returns it. Bind the "Changed" event from the expression to the delete service, so that it gets called each time the "DeletedPropertyId" changes. Notice that for this to happen, the delete service needs to be defined at the containing mashup level and no longed at the cell mashup, like you did before.

Lastly, bind the service invoke complete of your delete service to the service that pulls the data to be displayed in the collection.

Top Tags