This topic is locked
[SOLVED]

Show/hide controls depending on the current list's mode

5/23/2024 11:27:33 AM
PHPRunner General questions
P
polat author

Hi,

Despite searching in the forums, I couldn't find a solution to the following issue. Perhaps I didn't use the correct keywords.
Here it is:
I have a button in a list view's row that should only be visible for inline add/edit actions and not when the list is merely displaying data. In short, I need to detect the list's current mode and change the button's visibility accordingly, preferably server-side (PHP) or with JS.
Any help would be greatly appreciated.

A note to the developers of PHPrunner: I haven't checked the latest version, but I "strongly" suggest implementing a flexible "visibile if" setting for every control in design mode that accepts PHP or JS statements.
I guess it is not as easy as it sounds but I assure you this feature would be highly appreciated by many PHPrunner developers.

C
Chris Whitehead 5/23/2024

What do you mean by "I need to detect the list's current mode" I was thinking there's only one mode. I only ask so I can understand your issue.

P
polat author 5/24/2024

When you have a "list" page and enable "inline add" or "inline edit", you have a small edit button at the left side of all rows.
When you click that, the list goes into edit mode (in my terminology)
I need to detect this and hide my button if the row is not in edit mode (or similarly add mode, if that is something different)

(I've marked as solved by mistake, and couldn't revert it)

img alt

C
cristi 5/24/2024

On list page javascript onload:

pageObj.getItemButton('your_custom_button_id').addClass('trt');

//you also need to control what's happening after save
this.on('afterInlineEdit', function( fieldsData ) {
pageObj.getItemButton(''your_custom_button_id').addClass('trt');
} );

this.on('afterInlineAdd', function( fieldsData ) {
pageObj.getItemButton(''your_custom_button_id').addClass('trt');
} );

On add page javascript onload

pageObj.getItemButton('your_custom_button_id',row.recordId()).removeClass('trt');
// you need to control what's happening if user click cancel
inlineRow.onCancel = function(){
pageObj.getItemButton('your_custom_button_id',row.recordId()).addClass('trt');
};

same code on edit page javascripot onload:

pageObj.getItemButton('your_custom_button_id',row.recordId()).removeClass('trt');

inlineRow.onCancel = function(){
pageObj.getItemButton('your_custom_button_id',row.recordId()).addClass('trt');
};

In editor -> custom css add a class "trt" - or what name you want just be sure to change that name in the code above:

.trt{
display:none;
}
P
polat author 5/24/2024

Thank you very much Cristi!
I really appreciate your help on this.
You did not only solve my problem but also helped me understand the logic behind it.

Maybe it was obvious but I was surprised that although I'm not using usual add/edit pages, their events are still called by inline add/edit actions.