I'd like to get some help on an issue I'm having. I have a button that submits a page , I would like to be able to hide the button by default and show it if the value of a filed changed from "under waiting" to "accepted" or "refused" only. i tried to do that using dynamic action show and hide but i can not .What is the best way to make this happen.
Hard to say what is wrong with your code if the only hint you give is "i can not" :).
This works for me:
Create a page with a region that has item P85_SELECTLIST, a hidden item P85_OLD_STATUS and a button SUBMIT.
create a computation on P85_OLD_STATUS (process point: after P85_SELECTLIST has been initialized) of type item with value P85_SELECTLIST. This sets P85_OLD_STATUS to the value that P85_SELECTLIST has at page load.
define P85_SELECTLIST as "Static Values" with values:
Create a dynamic action on page load with action "Hide" button SUBMIT.
Create a dynamic action on change of P85_SELECTLIST (note that the values are the return values, not the display values). Add a server side condition to this dynamic action (this will ensure the dynamic action never fires if the initial value is not UNDERWAITING).
Add a true action of "Show" button SUBMIT to the dynamic action.
Add a false action of "Hide" button SUBMIT to the dynamic action.
That's it. If initial value is "Other", changing the value has no effect. If initial value is "UNDERWAITING" and it is changed to ACCEPTED or REFUSED button is shown.
Related
Type:
"Hidden:
Items that are included within the page source but are not rendered. Hidden item values are saved in session state. They are generally used to store values required by page processing or other page items, but should not be displayed to the end user."
Server side condition:
"Never:
The component is never rendered."
If an item's type is set to hidden, is it necessary to set the server side condition to never? Or is that superfluous?
Thanks in advance.
If the question is just about show or don't show, yes. it's unnecessary!
But a hidden item still existing in the page, it's just not showed to the user. You can see it pressing F12 and checking then in your HTML page. You can use hidden items on pl/sql process, dynamic actions or acessing it with javascript or jquery.
The server side condition remove the item of your HTML page and you can do nothing in these items.
I have a form that contains a select box and a text field.
The text field is displayed dynamically based on the selectbox selection. If the value of selectbox is "Yes", then the text field will be displayed and vice versa.
I am running an rspec test and filled the select box value with "Yes"
select 'Yes', from: 'property[have_water_bills]'
Now i want to fill a value on the text field
fill_in 'property[irrigation_cycle_count]', with: 5
But i am getting the following error.
Capybara::ElementNotFound:
Unable to find field "property[irrigation_cycle_count]"
That is, capybara cannot find the dynamic element. Does anyone know how to fix this?
Poltergeist doesn't gemerate a click event when choosing an item from a select. It generates a focus on the option, change on the select, blur on the option. It is more like if a user selected the option with keyboard instead of using a mouse. You probably should be doing the logic to display your text field on the change event anyway so that it works if people use a mouse or a keyboard to navigate around your page. It also makes more sense to run your show/hide logic on the change event because that's what you actually care about, not clicks.
Finally got this to work using the following piece of code
page.execute_script("$('#have_water_bills').val('true').trigger('click')")
I have a apex report page where there are multiple submit buttons for each region of charts display. Each submit button is supposed to have same dynamic actions- the dynamic action is supposed to run if user does not selects any data so an error message will pop up and this dynamic action I want to work for all the buttons, so instead of adding dynamic action which is common for every button , I want to define it somewhere in the code so that it can be called during click of any button.
How this can be done?
What you can do is assign the same CSS class to all the buttons you want your dynamic action to fire on. Let's say you assign a class .mybutton to all the buttons in your chart regions.
Second create your dynamic action.
Event: Click
Selection Type: jQuery Selector
jQuery Selector: .mybutton
Define the condition if you need to. Go on with Action etc.
So now your dynamic action will be fired whenever the user clicks on a button with the .mybutton class.
If you need to identify each button by ID when clicked and your action is Execute JavaScript Code, you can use thisTriggeringElement.id.
For the particular Dynamic Action, in Condition region, under Condition Type you can select Request is contained within Expression 1 and give your request(button request) in Expression 1
We have a rendering listing the selected items in a TreeSelect in the current item. In our case we call them "Tags" (1)
We have added a Field Editor Button to the component to let the editor change selected items. (2) (As described on for example Adding a custom component)
When an editor clicks (2) the editor window (3) it is opened in a dialog. The editor may select different items(called tags in our case) using the TreeSelect.
When the editor presses the ok-button (4) the values are set.
Now to the problem:
The values are actually set as they get stored when the editor presses the Save button but we want our list on the page (1) to immediately reflect the set items when the editor presses the ok-button (4), i.e. before having to actually save the whole item.
How do we achieve that?
(I am in contacts with Sitecore support but so far I have not gotten any answers...)
Update
After a lot of conversation with the support we still have no useful solution.
We tried turning it into a field renderer displaying the links.
What worked was:
The field do get updated when you have edited it in the popup field editor. (but...)
It looks good the first time when page is loaded.
You can make a WebEdit button with commands to edit the field and add it as Custom button to the field (register <command name="webedit:fieldeditor" type="Sitecore.Shell.Applications.WebEdit.Commands.FieldEditor, Sitecore.Client"/> and set Click on the button to webedit:fieldeditor(command={3473DDA1-2983-493C-AF7A-054C75AA7AD3},fields=NameOfField where the guid points to itelf and an "Icon" is set on it.)
What didn't work was:
The field get updated by the raw value, not what I want to display. Server code is involved, but not in the rendering of html-code.
When I want to edit the value in the field editor, the value sent to the field editor is not the raw value but what actually is displayed on the page. (I guess this can be solved somehow)
The issue to the support turned into a feature request to let the server be involved in rendering the field, not just sending a new value to the JavaScript updating it. The server does the first rendering so when it already is involved in updating, it should be allowed to do the rendering the following times too.
We have decided to not spend more time on this right now (we have other things to do too.) and have a bad editor experience as the field not get updated until the editor actually saves the item.
Still we have no suitable solution for this issue. If you want to keep working on it and want a reference to my issue it is 439059.
This may not be useful here. I've done this in normal sites, but not in Sitecore. But, here's one possibility....
This is a situation where you would pass a callback function to the child popup window. This callback will cause the caller / parent window to re-read/re-load the information that was just updated by the child.
Example:
User presses (2) to open Editor Window(3) (Editor window is opened and the Callback function is passed as a parameter)
User presses "OK" button (4). The "OK" button event handler updates the changes, then calls the Callback function which re-loads the now updated information, and closes the popup window.
Once the popup closes, the parent window now displays the information that the popup/editor just updated.
This takes some client side javascript (jquery) development but it is quite do-able normally.
I am looking for the best way to update a CPropertyPage once it is clicked. Currently, my pages receive it's information during OnInitDialog(). However, when the user does something on page one, it can effect what is on page two.
The only solution I can think to use is an "Update" button. Once the button is clicked, the page refreshes its information by calling the same functions that take place during OnInitDialog(). Is there an event that occurs when the user clicks on a different CPropertyPage of a CPropertySheet?
Using an "Update" button is poor design because it requires the user to force the update. Instead, you should look to maintain the state of the values that could cause the update. This can be done in a structure or class object that can then be made accessible to CPropertyPage::OnSetActive of the page that needs the updated values. OnSetActive is called just before the page is to be made the active one. It's your opportunity to update values on the page before it displays.