Hello Great to find this community!
Sorry about this obscure request – I am stuck!
I have a ListView Region and triggered by an onClick() event, I want a DynamicAction to use JavaScript Expression to pick the item I selected on ListView – and then call a PL/SQL Stored Proc with that ID. That’s it.
The trouble is I do not know how to catch the ID and also to construct a Selector in JavaScript.
1.. CREATE A LIST VIEW AS LIKE
SELECT DEPTNO,DNAME,LOC FROM EBA_DEMO_CHART_DEPT
MAKE A STATIC ID LIKE– listView
2.. GOTO ATTRIBUTE SECTION OF LIST VIEW
SETTING– CHECKED “ADVANCED FORMATTING”
List Entry Attributes ==> data-id=&DEPTNO.
Text Formatting—> <h5>&DNAME.</h3> <p>DEPTNO: &DEPTNO.</p>
Counter Column ==> DEPTNO
Link Target===> NO LINK DEFINED
3.. CREATE DYNAMIC ACTION
EVENT– CLICK
SELECTION TYPE= JQUERY SELECTOR
jQuery Selector== #listView li
ACTION =>EXECUTE JAVASCRIPT CODE LIKE
alert($(this.triggeringElement).attr(‘data-id’));
Sorry Afzal ~ I only just saw your post. Thanks! I will give this a try.
OK, I followed your instructions.. thanks again.
When I run it, I get an error exactly when the form is loading..
Uncaught Type Error: “apex.da.initDaEventList is not a function”
and:
Uncaught syntax error: “Invalid or unexpected token”
Interestingly, when I remove the erroneous Dynamic Action – at least, the ListView shows up with the TextFormatting exactly like you have written:”<h3>&DNAME.</h3> <p>DEPTNO: &DEPTNO.</p>”.
In fact, I am able to inspect a random item in the JavaScript console which brings up the relevant item like here:
<li data-id=”1229″ class=”a-ListView-item ui-body-inherit has-count”><h3>first_name</h3><p>ID: 1229</p><span class=”ui-li-count”>1229</span></li>
in my example &ID. is the key (&DEPT_NO. in your example) – so that is fine.
The span class is duplicate (its probably the Universal Theme doing its thing).
I posted the above to give you an idea of where the issue might be ~ a wrong ‘selector’ maybe?
… Probably a good time for me to learn some JavaScript, clearly :-/
Quick update: I have isolated the syntax issue to here this line: alert($(this.triggeringElement).attr(‘data-id’));
The Dynamic Action, as per @afzal ‘s advice correctly responds to selecting a ListView item.
I then changed the DA with the JavaScript:
var xTE = this.triggeringElement;
alert(xTE.innerText);
This correctly shows the inner text, which means that I am on the right track.
However – a new problem is that when I use the search feature of the ListView, the Dynamic Action does not work anymore. Very confused.
Helllo again.. It looks like Jeff Kemp’s article here has some potential solutions – he has used an Interactive Grid example and it does not exactly translate to a ListView. I just wish I knew JavaScript a bit better..
http://jeffkemponoracle.com/tag/javascript/
.. it does not exactly translate to a ListView. I just wish I knew JavaScript a bit better because I cannot even get this to evaluate in this case.
this.triggeringElement