This discussion is archived
1 2 Previous Next 18 Replies Latest reply: May 30, 2013 1:08 PM by leckj RSS

How to programatically click the LINK icon in first row of report

leckj Newbie
Currently Being Moderated
Hello,

I want to programatically (using jQuery) click on the LINK icon of the first row of a form with report
so that the data on the first row is displayed in the corresponding table items in the form without the
user having to click on the link.

From Firebug, the link icon is in <td headers="LINK">.

Please show me how to use this to click the link.

Thanks

Leckraj
  • 1. Re: How to programatically click the LINK icon in first row of report
    kvlek Journeyer
    Currently Being Moderated
    Hi Lekreaj,

    You can do such that with javascript. Look at the api description for apex.event.trigger here => http://docs.oracle.com/cd/E37097_01/doc/doc.42/e35127/javascript_api.htm#autoId8
    You need to give the link a name or id which you can refer to as an jquery selector.
    It will look something like this
    apex.event.trigger('JQUERY_SELECTOR','click','')
    Regards,
    Kees Vlek
    -----
    Company: http://www.orcado.nl
    Blog: http://www.orcado.nl/blog/blogger/listings/69-kvlek
    Twitter: http://www.twitter.com/skier66
    If the question is answered please change it to answered and mark the appropriate post as correct/helpfull.
  • 2. Re: How to programatically click the LINK icon in first row of report
    leckj Newbie
    Currently Being Moderated
    Hi ,

    I get this sinking feeling whenever Apex asks for a jQuery selector.

    This is as far as I have been able to get :

    To check I created a button with Redirect to URL and code--> javascript:apex.event.trigger($("#LINK"),'click','');

    When I inspect the pencil icon (which I want to click) in the row with firebug, it says <td_headers="LINK">

    When I click on the button,this would trigger a click on the Link in the first (and only) row,if it exists. Of course, nothing happens.


    Can you help?

    Regards

    Leckraj
  • 3. Re: How to programatically click the LINK icon in first row of report
    kvlek Journeyer
    Currently Being Moderated
    Hi Leckraj,

    If you setup an example on apex.oracle.com i will look into it for you.

    Regards,
    Kees Vlek
    -----
    Company: http://www.orcado.nl
    Blog: http://www.orcado.nl/blog/blogger/listings/69-kvlek
    Twitter: http://www.twitter.com/skier66
    If the question is answered please change it to answered and mark the appropriate post as correct/helpfull.
  • 4. Re: How to programatically click the LINK icon in first row of report
    Tom Petrus Expert
    Currently Being Moderated
    The jQuery selector would be
    "td[headers='LINK']:eq(0) a"
    which could be made more efficient by for example providing a more specific selection, such as within which table element to look for the td elements.
    This will select all td elements ("td") with the headers attribute set to 'LINK' ("[headers='LINK']"), select only the first element (":eq(0)"), and then select the anchor element within ("a'), which is the actual link.
    Emulating click could be done with
    {code}$("td[headers='LINK']:eq(0) a").click();{code}
    If you get a sinking feeling when asked for a jQuery selector, then why don't you read up on it a bit? You can find the excellent documentation on the several selectors <a href="http://api.jquery.com/category/selectors/">in the jQuery docs</a>, and there are plenty of blogposts available on the web which can help you greatly!

    Though I really wonder why you would need to do this. You don't want the user to have to click the link. So what are they clicking instead? Are they clicking anything? Do they have to click anything? Why would you have them sit through the useless render?
  • 6. Re: How to programatically click the LINK icon in first row of report
    leckj Newbie
    Currently Being Moderated
    Hi,

    Many apologies for taking up this thread late.

    It also seems that my nicely constructed previous post explaning my problem in detail was "truncated" during posting !

    The code suggested is not working for me
    $("td[headers='LINK']:eq(0) a").click();
    I have created a dynamic action on page load with Action: Execute Javascript Code,

    True Action: Execute Javascript code, Fire on Page Load,jQuery selector "td[headers='LINK']:eq(0) a"
    and code $("td[headers='LINK']:eq(0) a").click();

    but there is no action.

    The idea is to programatically click the LINK on the first (in my case,the only row) on page load,thus populating the report fields which is the default APEX behaviour.

    Here are a few lines of HTML from firebug that may help
    <th id="LINK"><span class="hideMeButHearMe">Link</span>
    
    <td headers="LINK">
    <a title="Click to edit" h ref="f?p=78390:230:14637236919513::NO::P230_ROWID:ABRE6ZALUAAABT3AAA"><img alt="" src="/i/edit.gif"></a></td>
    (I've added a space in the href to make it display).

    Why is the dynamic action not working?

    Thanks

    Leckraj
  • 7. Re: How to programatically click the LINK icon in first row of report
    fac586 Guru
    Currently Being Moderated
    leckj wrote:

    The idea is to programatically click the LINK on the first (in my case,the only row) on page load,thus populating the report fields which is the default APEX behaviour.

    Here are a few lines of HTML from firebug that may help
    <th id="LINK"><span class="hideMeButHearMe">Link</span>
    
    <td headers="LINK">
    <a title="Click to edit" h ref="f?p=78390:230:14637236919513::NO::P230_ROWID:ABRE6ZALUAAABT3AAA"><img alt="" src="/i/edit.gif"></a></td>
    Quoting fragments of HTML from Firebug like this is unlikely to help. If your page source looks exactly like that, then the dynamic action will not work because the HTML is invalid. If you're selectively copying and pasting then we can't tell what you are actually doing. An example on apex.oracle.com is infinitely more useful.
    Why is the dynamic action not working?
    To reiterate what Tom said, the real questions are:
    >
    Though I really wonder why you would need to do this. You don't want the user to have to click the link. So what are they clicking instead? Are they clicking anything? Do they have to click anything? Why would you have them sit through the useless render?
    >
    Why not just get APEX to compute and set this value before the page is rendered? Is this all happening on one page, or is the link on one page and the form on another?
  • 8. Re: How to programatically click the LINK icon in first row of report
    leckj Newbie
    Currently Being Moderated
    Hello,

    I have set the page on workspace: MESLD02
    username/password: test/test,

    application: test01.

    On Page 2: Report 1

    What I want is to click the LINK icon programatically every time the page load so that the Form on the next page (page 10) displays.

    What I did:

    Create a Dynamic Action :DISPLAY_FORM, fires on Page Load

    True Action: Execute Javascript Code, Fire on Page load:Yes, Selection Type:jQuery Selector, jQuery Selector:"td[headers='LINK']:eq(0) a"

    Code is:
    $("td[headers='LINK']:eq(0) a").click();
    As usual,No Action.

    Although here,this does not make any sense as part of a work flow,in the context I plan to use it,this action is desirable.

    Please show me what is wrong, as I seem to be repeating that same mistakes in my Dynamic Actions,most of which are not working.

    Thanks.

    Leckraj.
  • 9. Re: How to programatically click the LINK icon in first row of report
    fac586 Guru
    Currently Being Moderated
    leckj wrote:

    What I want is to click the LINK icon programatically every time the page load so that the Form on the next page (page 10) displays.
    This looks suspiciously like an XY Problem.

    What's the purpose of this? Doing so means that this page will never be properly displayed to the user: they'll always end up on page 10. Why bother with the initial page?
    Although here,this does not make any sense as part of a work flow,in the context I plan to use it,this action is desirable.
    Describe this work flow/context. Possibly there are other possibilities that you haven't considered.
  • 10. Re: How to programatically click the LINK icon in first row of report
    leckj Newbie
    Currently Being Moderated
    I am using one of these forms with a report on the same page containing the records from a particular table.
    When you click on the link in the record, the data for that particular record, is posted in the form fields to be
    edited etc..

    Now, when a user logs in in my application,all the data in the various forms relate ONLY to that person,this is how
    it was required,and it works.

    When a user logs in and navigates to the page where his personal details are maintained,there will obviously be
    only one record in the report. As this will an internet facing application, I do not want to have to tell the user
    "If you want to change your background data ,go to the top of the page,find something looking like a pencil,click
    on it,the data will then be displayed,and you can make the changes."

    If on page load,I check if there is a record on top and one of the mandatory in the fields is NULL,i do a programmed
    click et voila.

    This programmed clicking is also something I might use elsewhere,so its good to know.
  • 11. Re: How to programatically click the LINK icon in first row of report
    Tom Petrus Expert
    Currently Being Moderated
    Why do you have a report on top of this form if it only ever will contain one record? The entire page is rendered, and when finished (cause of page load javascript) it'll suddenly navigate. Chances are high (application over the internet) that the page will show at the least partially before the navigation will occur. I'd say that from a user perspective this is at least as annoying as having to click an extra link. And all that to render 1 record and get a column link?
    Is this report used by any other person/role so that more than 1 record will display? You make it seem as if you'd also want to check for the amount of rows, and if only 1 row (because of user restriction) then click the link.
    I'll reiterate though: Why do you have a report on top of this form if it only ever will contain one record?
  • 12. Re: How to programatically click the LINK icon in first row of report
    leckj Newbie
    Currently Being Moderated
    I probably chose the wrong report !

    There are so many choices, and I am new to this, and I already have worked on the validations,display etc. on this
    page,but I can change for the correct one,specially if there is any risk.

    But still if you can help with the clicking thing,I know I'll need it somewhere else sooner or later.

    And its always nice to see jQuery and Dynamic Actions at work. You see it doing one thing, and it give you ideas
    for other uses.

    Regards.

    Leckraj
  • 13. Re: How to programatically click the LINK icon in first row of report
    kvlek Journeyer
    Currently Being Moderated
    Hi Leckraj,

    I changed your app on apex.oracle.com.
    If you enter the page (2) for the first time it will send you to the form page (10).
    If you click cancel it will return to page 2 and stay there.

    Hope this helps you enough to get further with it.

    Regards,
    Kees Vlek
    -----
    Company: http://www.orcado.nl
    Blog: http://www.orcado.nl/blog/blogger/listings/69-kvlek
    Twitter: http://www.twitter.com/skier66
    If the question is answered please change it to answered and mark the appropriate post as correct/helpfull.
  • 14. Re: How to programatically click the LINK icon in first row of report
    leckj Newbie
    Currently Being Moderated
    Hi Kees,

    Awesome. I put the code in my application and it works flawlessly and fetches the data in the form fields if the report has a row of data.

    However when there are no records yet in the report above, I get 404 error probably because the eq = 0 does not evaluate to anything.

    As there are 2 regions in the page, I need to check if the report region above has any rows.

    If I give the report a static ID of say "Report 1" and I know there is a mandatory column of "ID" in there,which should have a value if a row exists,

    how can I add a condition to ($v("P230_FIRST_TIME") != 1) to execute the DA only if a row exists.

    I know there is a jQuery.hasData() and I probably need to put something like td[headers='ID']:eq(0) in there,or maybe I'm totally wrong.

    Thanks

    Leckraj
1 2 Previous Next

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points