cancel
Showing results for 
Search instead for 
Did you mean: 

How to know the item pressed in a rule after onPress event

fjcarrasco
Active Participant
0 Kudos

Hi experts, I generate dinamically a page with a sectioned table and several sections where each section has a static object table and each has several static object cell. All ObjectCell call same rule at OnPress event.

In this rule, I need to know the item was pressed. I see the rule receives the SectionedTableProxy object and I don't see how to get some information about the item pressed. I don't really need to know the item but the object table or section so I would need the property "Name" of the ObjectTable, or the index of the ObjectCell control or the index of the section where the ObjectCell was pressed ...

I wouldn't like to create a rule for each ObjectTable due to I don't really know how many there will be and they could be hundreds.

Example:

Please any idea.

Thanks

Accepted Solutions (0)

Answers (5)

Answers (5)

fjcarrasco
Active Participant
0 Kudos

Hello bill.froelich.

I tryed out the method getPressedItem() but it didn't return anything either:

bill_froelich
Product and Topic Expert
Product and Topic Expert

I believe it may be due to the dynamic page context. I opened an internal ticket to look into the context issue further.

bill_froelich
Product and Topic Expert
Product and Topic Expert
0 Kudos

There appears to be a discrepancy in the context value passed when the page is dynamically generated versus a statically loaded page. I have opened an internal ticket for further investigation and will let you know what the are the next steps.

fjcarrasco
Active Participant
0 Kudos

Thanks bill.froelich

fjcarrasco
Active Participant
0 Kudos

Hello bill.froelich. I'm trying to get the selected item in on press event from the dynamic page. The "dinamicPageTop" in the screenshot is because I have to generate a new dinamic page based on the item was pressed.

I have a dynamic list of elements in the first object table and when you click on one of them I have to show a dinamic form with his subelements.

Thanks

bill_froelich
Product and Topic Expert
Product and Topic Expert
0 Kudos

So the elements object table on press calls the rule shown or is it calling a navigation action whose page metadata property calls the rule?

fjcarrasco
Active Participant
0 Kudos

Hi bill.froelich. The elements in the object table on press calls the rule shown.

In this rule I generate a form page dinamically and I call a navigation action where a I set the PageMetadata with this new page.

Thanks

fjcarrasco
Active Participant
0 Kudos

Hello bill.froelich thanks for your answer.

The point is no action binding is done when I press on the object cell. I don't know why. I build the complete page in a rule (generatepage.txt) with static content that I assign to a "PageMetadata" property in the navigation action.

context.getPageProxy().getActionBinding() returns a previous binding action and the properties I fill in the object field doesn't exists:

I've already try "binding.parent.debugstring" but "context.binding.parent" doesn't exisits.

Also, I notice that context.binding is same as context.getPageProxy().getActionBinding():

bill_froelich
Product and Topic Expert
Product and Topic Expert
0 Kudos

From the screen shots it looks like you are debugging the rule to create the page. How is the navigation action being called? Are you trying to get the selected item before calling your dynamic page or in the on press from the dynamic page?

bill_froelich
Product and Topic Expert
Product and Topic Expert
0 Kudos

For OnPress events on a collection, you can get the current item using getActionBinding(). Since it is a static Object cell you can then directly access the properties. For cells that are data bound getActionBinding() returns the whole data object for the corresponding row selected.

export default function StaticObjectCellOnPress(context) {
    let pageProxy = context.getPageProxy();
    let binding = pageProxy.getActionBinding();
    let title = binding.title;
    let subhead = binding.subhead;
}

I can't find a direct way to get the section name as an independent property. The closet thing would be the following

binding.parent.debugString;

--Bill