databaseplsqlinterfaceoracle-apextabular-form

How to enable select list when related checkbox is checked in interactive report in APEX 5.1


I have created an interactive report on SQL query in Oracle APEX 5.1 and i have added two more columns to query. One is checkbox for each row in report and other one is select list containing numbers for each row. SQL query is written below. What i want to do is enabling select list when related checkbox is checked otherwise end-user shouldn't be able to select number from list. I know this can be done with dynamic actions but i couldn't point out solution.

Why i want to disable select list: I can reach returned value of check-boxes via array named APEX_APPLICATION.G_F01 by for loop in pl/sql. Inside the array, there are checked rows but I couldnt reach amounts of checked rows via APEX_APPLICATION.G_F02 which is array of values of select list because this array also contains amounts undesired, unchecked columns of values. I found solution on enabling select list when checkbox is checked.

QUERY:

SELECT  APEX_ITEM.CHECKBOX2(1,URUN.BARKOD) "Select", U.AD, MA.AD MAGAZA_ADI, FIYAT, APEX_ITEM.SELECT_LIST(
        p_idx           =>   2,
        p_list_values   =>   '1;1,2;2,3;3,4;4,5;5,6;6,7;7,8;8,9;9,10;10',
        p_show_null     =>   'YES',
        p_null_value    =>   NULL,
        p_null_text     =>   '-0-',
        p_item_id       =>   'f03_#ROWNUM#',
        p_item_label    =>   'Label for f03_#ROWNUM#') "Adet"
FROM URUNSATIS URUN, UYE UN, ADRES AD, ANLASMALAR AN, MAGAZA MA, URUN U
WHERE UN.USERNAME = :SESSION_USER_NAME AND UN.ID = AD.UYE_ID AND AD.APARTMAN_ID = AN.APARTMAN_ID AND AN.MAGAZA_ID = URUN.MAGAZA_ID AND MA.ID = URUN.MAGAZA_ID AND U.BARKOD=URUN.BARKOD
ORDER BY 1;

İdea behind this question: I want end-users to select a product from report and when they select checkbox of desired product they should able to choose amount of product that they want to order from market. I got stuck on this phase of app. I am open to any new idea for solving this problem.


Solution

  • You could use the p_checked_attributes option on the checkbox to keep track of which ones had been checked via a hidden item, and then have a dynamic action to disable / enable based on if the value is contained in a hidden item.

    So your select query would look something like this:

    SELECT 
        APEX_ITEM.CHECKBOX2(p_idx => 1, 
                            p_value => URON.BARKOD,
                        --    p_attributes => 'class="barkod"', use this value if you want to keep track after refresh
                            p_checked_values => :P1_BARKOD_LIST,
                            p_checked_values_delimiter => ',') AS "SELECT",
        U.AD, MA.AD MAGAZA_ADI, FIYAT, 
        APEX_ITEM.SELECT_LIST(
            p_idx           =>   2,
            p_list_values   =>   '1;1,2;2,3;3,4;4,5;5,6;6,7;7,8;8,9;9,10;10',
            p_show_null     =>   'YES',
            p_null_value    =>   NULL,
            p_null_text     =>   '-0-',
            p_item_id       =>   'f03_#ROWNUM#',
            p_item_label    =>   'Label for f03_#ROWNUM#') "Adet"
    FROM URUNSATIS URUN, UYE UN, ADRES AD, ANLASMALAR AN, MAGAZA MA, URUN U
    WHERE UN.USERNAME = :SESSION_USER_NAME AND UN.ID = AD.UYE_ID AND AD.APARTMAN_ID = AN.APARTMAN_ID AND AN.MAGAZA_ID = URUN.MAGAZA_ID AND MA.ID = URUN.MAGAZA_ID AND U.BARKOD=URUN.BARKOD
    ORDER BY 1;