Saving Current Values with Cascading LOVs - 0 views
-
cezarovidiu on 05 Jan 14"Saving Current Values with Cascading LOVs A friend, Monty Latiolais, recently asked an interesting question regarding cascading LOVs: Say you've got two LOVs...STATES and CITIES. They both default to 'ALL' and 'ALL'. Since CITIES is dependent on STATES, as soon as STATES is changed, CITIES is blanked out. What should happen is that CITIES gets re-evaluated as in the following example... let's say STATES is ALL and CITIES is "Houston". If one then changes STATES to "Texas", CITIES should remain "Houston" as that is a valid value for CITIES. So basically, is it possible to maintain the selected value of an item if that same value exists in the list of values after refreshing? That's a great question! Thanks to new events in the APEX framework and Dynamic Actions the solution is far easier than it would have been in the past! Click here to see the demo but continue reading to learn how it all works… There are a three main events you need to be concerned with when it comes to cascading selects: change apexbeforerefresh apexafterrefresh The change event is a standard part of JavaScript and the DOM. This event fires when the user manually changes the value of the select list but can also be triggered programmatically via JavaScript. The apexbeforerefresh and apexafterrefresh events are custom events in the APEX framework. They fire just before and just after AJAX requests refresh something on the page. The events work with many items and regions that utilize this technology. In this example we have two select lists: parent and child. If you change the value of the child select list then the change event will fire and that's it. But if you change the value of the parent select list a lot more happens to the child select. Here are some of the highlights: The current LOV values are cleared out The apexbeforerefresh event is triggered An AJAX request brings back new values. This only happens if optimize refresh is set to false optimize refresh is set to true and