Forum Stats

  • 3,836,764 Users
  • 2,262,185 Discussions
  • 7,900,102 Comments

Discussions

How to get Text Item Custom Attributes

hszero
hszero Member Posts: 52
edited Sep 23, 2008 4:09PM in APEX Discussions
Hello all,
I am running a report creation like the select below...

SELECT apex_item.text (1,
printer,
20,
2000,
'rownum=' || '"' || ROWNUM || '"'
) AS printer
FROM DUAL

with no issues.

But I have questions on how to retreive the rownum attribute I have created?
I guess for that matter any custom attribute I choose to add, as there will be others.

I would like to be able to get those custom attributes in a for loop as shown below.

Any Ideas?

FOR i in 1..APEX_APPLICATION.G_F01.count
LOOP
?APEX_APPLICATION.G_F01(i).rownum?
END LOOP;

Answers

  • Anthony Rayner-Oracle
    Anthony Rayner-Oracle Member Posts: 732 Employee
    I don't think it's possible to access custom HTML attributes from PL/SQL code, at least not in a way that is out-of-the-box APEX. But you could use additional hidden columns to store additional values for each row. For example:
    select apex_item.text(1, printer, 20, 2000) || 
        apex_item.hidden(2, rownum) as printer
    from dual
    Which would then be accessed as normal...
    APEX_APPLICATION.G_F02(i)
    Any good?

    Anthony.

    --------------------------------------------------------------
    http://anthonyrayner.blogspot.com
  • hszero
    hszero Member Posts: 52
    Thanks Anthony,
    I also expected to have issues with getting custom attributes but thought it was worth asking as I couldn't come up with anything else at the time. But as similar with many problems, time heals.

    Here is the fix I put in place, and am posting as I am sure this is valuable to additional apex users.

    The problem I had was that I needed to update only the rows that were denoted by the checkbox. But what made this more difficult was that the update has to get not only data from the report items but also from data the user entered in a text field. So what I ran into while looping was, apex_application.g_f01.count had a counter of only appx. 2, or what ever else the user checked. But in reality the info I had to get from the form was on record say 7 and 9. So in short, the indexes are different from checkboxes to textfields. To get around the following code worked... hope I didn't take the hard way to solve this problem...

    --report definition
    SELECT apex_item.text (1, xrt.printer) AS printer,
    apex_item.checkbox (2, xrt.report_id) AS PRINT,
    apex_item.hidden (3, xrt.report_id) AS hidden
    FROM dual

    --update script
    FOR j in 1..APEX_APPLICATION.G_F02.count
    LOOP
    FOR i in 1..APEX_APPLICATION.G_F01.count
    LOOP
    IF APEX_APPLICATION.G_F02(j)= APEX_APPLICATION.G_F03(i) THEN
    UPDATE dual SET printer = APEX_APPLICATION.G_F01(i)
    WHERE report_id = APEX_APPLICATION.G_F02(j);
    END IF;
    END LOOP;
    END LOOP;

    Not exactly intuitive, but I am sure others have hit this issue before.
    Hope this helps,
    Hayden
This discussion has been closed.