My requirement is to change the pxObjClass of a list type editable Data Page during runtime on click of hyperlink from a modal dialog.
Actually I have a Table layout with Add Question button in the action bottom area of the table. On click of Add Question the modal dialog will open up having hyperlink on the modal dialog. e.g. Question, Question Group. The section is in say for example ABC-Data-Element.
So, if I click on Question, then the pxObjClass for this added item (in the respective pxResults index) will be changed at runtime to ABC-Data-Element-Question.
Similarly if I click on Question Group then the class will change at runtime to ABC-Data-Element-Group.
I tried to change the pxObjClass using Page-change-class method but it’s not allowing to change the class and stating that the . pxResults can’t be modified as it’s read only, however I am using an editable Data Page.
@Anupam.Pal From an OOP perspective, it seems that your main list must be a list of -Element objects that can contain different kind of derivated objects (refer to this academy article).
This is my idea (all these steps can be done in a single data transform):
Create a new page, its class will depend on the “Question” or “Group” link.
Copy the necessary data from the current -Element object to the created page.
I just tried on my end and when using Page-Change-Class on a list entry for an editable data page, it gives me the same error as you. If I switch the table source to pagelist property or a custom clipboard page it works fine.
Setting .pxObjClass directly with a property set is working correctly with editable data page however.
So you have two options
Switch to a pagelist property instead of the editable data page
Use Property-Set .pxObjClass = “your new class” directly instead of the Page-Change-Class
@Deivit Thanks! The above approach worked fine. Now if I have to save this list type data page into one data type, what would be the way out? I tried with savable data page but since the pxObjClass is of different class based on the different hyperlink, it’s not saving the instances to a data type of class e.g. ABC-Data-Elements. As per my design I thought I will be able to save instances of different pxObjClass into one data type using Savable data page but it’s not working. Is there any way to achieve this?
@JoeH9464 Hi. It worked the same approach which @Deivit suggested. You have to basically do an Append not to the Primary page but instead you should explicitly keep .pxResults in the Target and in the source you need to keep the Temp page. Doing this it didn’t throw the error.
@JoeH9464 Yes ideally it should work because it’s running in the context of the referenced data page via a pagelist property but it throws error. Even if you try by using source of the table layout as a data page (editable one), that also doesn’t work. The error says that .pxResults can’t be modified as its read only which is a bit weird in my opinion.
Additionally page copy also doesn’t work from temp page to the primary page.