This discussion is archived
10 Replies Latest reply: Feb 13, 2013 7:10 AM by jfosteroracle RSS

Dynamic Action based on value in Tabular Form

jfosteroracle Newbie
Currently Being Moderated
Greetings,

I would like to use a dynamic action to disable a button based on the value entered/selected in a field in a tabular form. So for example, if someone enters the value 'LKSG' then a button is disabled (in this case, the 'Add Row' button).

How would I do that using the Dynamic Actions tools? When I create a dynamic action I see that my "Selection Type" choices for firing a dynamic action are item, button, region, DOM object, jQuery Selector. I am not sure how to proceed for using a field in a tabular form to do the firing. Or if it is possible.

I am using APEX version 4.1.1.00.23

Thanks in advance!!

John
  • 1. Re: Dynamic Action based on value in Tabular Form
    Tom Petrus Expert
    Currently Being Moderated
    You can target anything on a page with a jQuery selector. If you aren't familiar with that, here are some pointers:
    - http://docs.jquery.com/Tutorials:How_to_Get_Anything_You_Want_2
    - http://api.jquery.com/category/selectors/

    Other than that there is not much we can help you with without more details about the structure of your tabular form.
  • 2. Re: Dynamic Action based on value in Tabular Form
    jfosteroracle Newbie
    Currently Being Moderated
    Thanks. I will check out those links. If this helps as far as the structure of my tabular form:

    - I have a tabular form with a field that is a pull-down list.
    - When certain values are selected (PDSG for example) I would like that to trigger a dynamic action to disable the 'Add Row' button.

    Is there other information I can give on the structure of the tabular form?

    Thanks!
  • 3. Re: Dynamic Action based on value in Tabular Form
    Tom Petrus Expert
    Currently Being Moderated
    The select list that you want to check the value of (it is a select list right? As in, an actual "select" html element?): what is the column header of it? With that it should be possible to construct a selector for it. (There are actually plenty of examples around, too!)
  • 4. Re: Dynamic Action based on value in Tabular Form
    jfosteroracle Newbie
    Currently Being Moderated
    Yes, it a Select List (in the Column Attribute - Display As) for a column in the Tabular Form . It is a 'Select List (named LOV). The actual column name is 'SPECIES'.

    Hopefully this gives enough information.

    John
  • 5. Re: Dynamic Action based on value in Tabular Form
    TobiP Explorer
    Currently Being Moderated
    But why do you want to manipulate a button that concerns the eniter table based on a selection that concerns only one datarow?
  • 6. Re: Dynamic Action based on value in Tabular Form
    jfosteroracle Newbie
    Currently Being Moderated
    The "Add Row" button adds new rows to the Tabular Form. If the user enters a certain code for the field SPECIES, then the customer wants it to work so the user cannot add any additional rows to the Tabular form.
  • 7. Re: Dynamic Action based on value in Tabular Form
    Tom Petrus Expert
    Currently Being Moderated
    Edit the "ADD" button and give it a static id ("addRowButton", for example)

    Create a dynamic action
    <ul>
    <li>Event: Change
    <li>Selection Type: jQuery Selector
    <li>jQuery Selector:
    td[headers='SPECIES'] select
    <li>Condition: equal to (You can always set the condition to "in list" to account for multiple values.)
    <li>Value: PDSG
    </ul>

    True Action:
    <ul>
    <li>Either you use a "Disable" or "Hide" action. Disabling will not hide the button but will not allow clicking it anymore.
    <li>Uncheck "fire on page load"
    <li>Affected Elements
    <li>Selection Type: jQuery Selector
    <li>jQuery Selector: #addRowButton (or any static id you assigned to the button).
    </ul>

    You might consider setting a condition on the "Add Row" button though which will check if there are records with the specified values already.
    If your form allows pagination, then javascript will be insufficient as you can't tell if there already are records defined from what is currently on the page. If your tabular form only will have one page then you could discern this through javascript, but we don't know that.
  • 8. Re: Dynamic Action based on value in Tabular Form
    jfosteroracle Newbie
    Currently Being Moderated
    Tom - this is very helpfuL! A couple questions:

    - I am using a 'template based button'. To use the Static ID for the button, I see that the template must include the #BUTTON_ID# in the template. I added the #BUTTON_ID# in the template like this:

    <table cellpadding="0" cellspacing="0" border="0" summary="" class="t16Button" #BUTTON_ID#>
    <tr>
    <td><img src="#IMAGE_PREFIX#themes/theme_16/t16Button1Left.gif" width="3" height="18" alt="" /></td>
    <td class="M" valign="middle">#LABEL#</td>
    <td><img src="#IMAGE_PREFIX#themes/theme_16/t16Button1Right.gif" width="3" height="18" alt="" /></td>
    </tr>
    </table>

    Is this where the the BUTTON_ID should go, in the <table ...> ?

    After adding this, it isn't working for a template based button. But if I switch the button to a HTML button, your method works great!

    - Also, in your solution you have True Action -> jQuery selector: #addRowButton. Is that correct or should it be #addRowButton# ? (# at the end)

    Thanks for your help!
    John
  • 9. Re: Dynamic Action based on value in Tabular Form
    Tom Petrus Expert
    Currently Being Moderated
    jfosteroracle wrote:
    Tom - this is very helpfuL! A couple questions:

    - I am using a 'template based button'. To use the Static ID for the button, I see that the template must include the #BUTTON_ID# in the template. I added the #BUTTON_ID# in the template like this:
    <table cellpadding="0" cellspacing="0" border="0" summary="" class="t16Button" #BUTTON_ID#>
    <tr>
    <td><img src="#IMAGE_PREFIX#themes/theme_16/t16Button1Left.gif" width="3" height="18" alt="" /></td>
    <td class="M" valign="middle"><a href="#LINK#" style="padding-left:5px; padding-right:5px;" class="mrrpList">#LABEL#</a></td>
    <td><img src="#IMAGE_PREFIX#themes/theme_16/t16Button1Right.gif" width="3" height="18" alt="" /></td>
    </tr>
    </table>
    Is this where the the BUTTON_ID should go, in the <table ...> ?

    After adding this, it isn't working for a template based button. But if I switch the button to a HTML button, your method works great!
    That is of course the difference between the two buttons: how they react and most importantly how they are marked up. An HTML button is an actual <button> element, while the template one obviously isn't. Also, the HTML button can be disabled, while the template one can't.
    So if you want to keep using the template based button, do not use the "disable" action, but use "hide". I'd not advise to implement a disable-like behaviour for the template button as that involves even more javascript/jquery, which i'd avoid if you're not comfortable or familiar with it.
    Having said that, I'd say that for this specific case adding the #BUTTON_ID# string in the table element itself will work great as this will cause this whole element to be hidden. If you'd only added it to the anchor tag in the second cell then you'd get weird issues. You'll have to edit the template though, because your markup is not correct for the id to work: the substitution string will only substitute the given ID and not add the actual attribute (id=""):
    <table cellpadding="0" cellspacing="0" border="0" summary="" class="t16Button" id="#BUTTON_ID#">
    - Also, in your solution you have True Action -> jQuery selector: #addRowButton. Is that correct or should it be #addRowButton# ? (# at the end)
    Yes, that is correct. "#" is the jQuery selector for "select by id": http://api.jquery.com/id-selector/
    Also, this is the jQuery selector for the affected element of the true action, not to be confused with the dynamic action triggering element.
  • 10. Re: Dynamic Action based on value in Tabular Form
    jfosteroracle Newbie
    Currently Being Moderated
    Thanks so much for this information! In the template I changed it from "BUTTON_ID" to id=#BUTTON_ID# as you suggested. Now the button does gray out like it is disabled button actually still works. So it grayed it out but it just didn't disable the button.

    So I did as you suggested and changed it from Disable/Enable to Hide/Show. Works great!

    Thanks again for your help. Much appreciated!!

    John

Legend

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