Intercept value passed to item editor?

Hello! I'm trying to intercept the value that is taken from a DataGrid's GridColumn's itemRenderer and applied to the itemEditor, and vice-versa. I need to be able to format this value. However, my project is complex, so I may be focusing on the wrong idea in what I'm trying to accomplish. Please have a look and let me know if there's something else I could try.
I have a Spark DataGrid component (with ID dg) that I am dynamically populating from XML. I create an ArrayCollection from some nodes, and a regular Array from sub-nodes that is added as a property of the ArrayCollection. That ArrayCollection is then used as the dataProvider for the DataGrid.
Here is an example segment of a typical XML node and it's sub-nodes:
    <item name="physOrderTable" text="" type="notes">
        <cols>
            <col id="0" text="Day/Time" />
            <col id="1" text="Order Type" />
            <col id="2" text="Physician's Orders" />
            <col id="3" text="Physician's Signature" />
        </cols>
        <rows>
            <row id="r0" name="" text="">
                <col id="0"><![CDATA[Tues 15:24]]></col>
                <col id="1"><![CDATA[General]]></col>
                <col id="2"><![CDATA[BMP, CBC, Cardiac Enzymes, ABG, EKG STAT, NS@ 125 mL/hr, Blood Sugar AC & HS, 02 via NC to keep oxygen saturation above 97%]]></col>
                <col id="3"><![CDATA[J. Nelms]]></col>
            </row>
        </rows>
    </item>
Here is the code that reads through the XML and utilizes it:
    protected function sparkDG_creationCompleteHandler(event:FlexEvent):void
        trace("grid created");
        var colsList:XMLList = xml.cols.col;
        var rowsList:XMLList = xml.rows.row;
        colAL = new ArrayList();
        for(var i:Number = 0; i < colsList.length(); i++)
            var gc:GridColumn = new GridColumn();
            gc.maxWidth = 500;
            gc.resizable = false;
            gc.headerText = String(colsList[i].@text);
            gc.dataField = "col";
            gc.labelFunction = labelFunc;
            colAL.addItem(gc);
        for each(var row:XML in XML(value).rows.children())
            var rowArr:Array = new Array();
            for each(var col:XML in row.children())
                if(col == "")
                    rowArr[Number(col.@id)] = "_";
                }else{
                    rowArr[Number(col.@id)] = col;
            colAC.addItem({
                rowID: row.@id,
                rowName: row.@name,
                rowText: row.@text,
                col: rowArr
        dg.columns = colAL;
        dg.dataProvider = colAC;
So I build the header for the DataGrid first, telling it to use the "col" dataField, which corresponds to the .col property of the colAC ArrayCollection. That .col property is the array of values for each cell of that row.
Now this part of code is important, as it displays the relevant index of the .col array by using the .columnIndex:
    private function labelFunc(item:Object, column:GridColumn):String
        var displayText:String;
        var valArr:Array = new Array();
        if(column.dataField == "col")
            valArr = item[column.dataField];
            displayText = String(valArr[column.columnIndex]);
        return displayText;
This is the only method I've been able to use to achieve the desired result. This all works fine, if all I want to do is merely display information. But I need to be able to edit the values in each cell, and apply this back to the dataProvider, as I need to rebuild XML with the updated values later.
I have tried everything I can possibly think of to be able to do this. I built my own itemRenderer, then my own itemEditor, then scrapped them because it felt like I was re-inventing the wheel. But was I? I tried reading through the code for the DataGrid, GridColumn, and related classes, but I couldn't find any reference to the itemEditor beyond it being an IFactory. I have no idea where or how it tells that IFactory to be a text input or whatever it is.
Here is my issue:
When I turn on the DataGrid's editing, and double-click a cell, it takes the entire array of the col dataField for that column's cell, converts that array to a string, and displays the entire string in the edit text box. If I cancel the editing, or save the editing, it sets the string to the .col property. Then the labelFunction tries reading that string as an array, and it crashes. I was able to get the typeof the col dataField and converting it to an array if it's a string, but I shouldn't have to.
I need to have it display just the value of the cell for that particular row and column when the instance of the itemEditor is created. When that value is changed, I need it to apply back to that column's index in the .col array of the dataProvider. So, similarly to how it displays information in the labelFunction, I need to edit the information and send it back.
I've seen lots of custom itemEditors and itemRenderers for GridColumns, but these are hard-coded in the MXML. My grid is almost entirely dynamically created, so that's unfortunately not an option for me, as I won't even know how many columns or rows there will be when the DataGrid is created. I tried using rendererIsEditor, but that only seems to be on the MXML instantiation of the GridColumn, as there's only rendererIsEditable in the ActionScript, and it doesn't seem to work (or I don't know how to use it as intended).
If anyone knows of a way to accomplish this, even just something else I should look at, I would greatly appreciate it!

Thanks for your response! I had seen that function before, but as there was nothing in it, I couldn't figure out if it was useful. Going back, I looked at the comments. I also found this website about item editors: The Item Editing Process
So, according to that, the data variable will contain the .col property of the dataProvider, right? I can trace data out as an object, but when trying to reference it as an array, it doesn't work.
Also according to that website, data is applied to value before prepare() is called, at which point data becomes a string. Doing this test in prepare(), I find that value is already a string. I can do a split() on the string or whatever to set the value how I need it (I think), but my life would be a lot easier if I could reference the cell's data directly and set value based on that.
<?xml version="1.0" encoding="utf-8"?>
<s:GridItemEditor xmlns:fx="http://ns.adobe.com/mxml/2009"
                  xmlns:s="library://ns.adobe.com/flex/spark"
                  xmlns:mx="library://ns.adobe.com/flex/mx">
    <fx:Script>
        <![CDATA[
            private var valueArr:Array;
            override public function prepare():void
                trace("prepare called");
                valueArr = new Array(value);
                trace("\tdata["+0+"]: "+data[0]);
                trace("\tdata["+columnIndex+"]: "+data[columnIndex]);
                trace("\tvalue: "+value);
                trace("\tvalueArr.length: "+valueArr.length);
                value = String(valueArr[columnIndex]);
            override public function discard():void
                trace("discard called");
                valueArr[columnIndex] = value;
                value = valueArr;
        ]]>
    </fx:Script>
</s:GridItemEditor>
And once that's accomplished, I believe what I did for discard() there should work correctly. What do you think?

Similar Messages

  • Name-value pairs in item editor

    I am setting up a datagrid that must have in some fields an itemEditor displaying a combobox with name/value pairs:
        <mx:DataGrid height="100%" width="100%" id="dgTaxa" editable="true">
                            <mx:columns>
                                <mx:DataGridColumn headerText="Codice" dataField="taxonCode" width="60"/>
                                <mx:DataGridColumn id="colFamily" headerText="Famiglia" dataField="family" width="80">
                                    <mx:itemEditor>
                                        <fx:Component>
                                            <mx:ComboBox width="80" labelField="familyId" dataProvider="{parentDocument.families}" >
                                            </mx:ComboBox>
                                        </fx:Component>
                                    </mx:itemEditor>
                                </mx:DataGridColumn>                           
                            </mx:columns>
                        </mx:DataGrid>
    This combobox has a dataprovider that it's this one:
    [Bindable]
    public var families:ArrayCollection = new ArrayCollection([
            { familyId:1, name:"cactacee"},
            { familyId:2, name:"liliacee"}
    My problem is that I want to show name as combobox labels, but get familyId as combobox values to send back to the webservice.
    Does anyone know how to help me?
    Thanks
    Paolo

    Thanks for the correct answer.
    I realized it's the right thing to be done.

  • How to pass Application Item value in Javascript function.

    Hi,
    I have the following javascript in the HTML Form Element Attributes properties
    I am on Page1 and passing P1_DEPT_NO page item value. This is working perferctly fine and I am able to get the exact value of the page item
    onchange="javascript:function1($x('P1_DEPT_NO').value);"I am on Page1 and passing Application Item G_DEPT_NO value.
    The problem here is, I am not getting the Application item value inside the javascript function.
    I tried using alert(); and it's giving me value as undefined
    onchange="javascript:function1($x('G_DEPT_NO').value);"Just want to know, how to pass the Application Item value in Javascript.
    Thanks,
    Deepak

    Deepak,
    I am not an expert at Javascript, but the suggestin I made was because javascript is a case-sensitive language.. and therefore onChange is not the same as onchange.
    Not quite sure if that is causing the problem.
    Application items are not associated with a page and therefore have no user interface properties.
    Therefore, as mentioned in another post, the rendering would not work for application items.
    If it is for a single item, used only in this page, you could create a hidden page item and use it fo your purpose
    If you still want to look at application items and AJAX, This page contains examples of using AJAX to solve problems like the one you mentioned.
    http://www.oracle.com/technology/obe/hol08/apexweb20/ajax_otn.htm#t1b
    Thanks,
    Rajesh.

  • How to pass apex item value into custom xml for chart or guage?

    Re-opening the old thread : Re: How to pass apex item value into custom xml for chart or guage?
    Which was not answered.
    Roel - Thanks. Its working - but in a semi quotes in the custom XML
    <pointers>
    <pointer value= '&P5_RUNNING_TOTAL.'
    <label enabled="true">
    <position placement_mode="ByPoint" x="50" y="15" />
    <format>{%Value}{numDecimals:1}</format>
    <background enabled="false" />
    </label>
    </pointer>
    </pointers>This question was helpful for us to resolving one recent thread : AnyChart - set Dial axis intervals dynamically?
    (Re: AnyChart - set Dial axis intervals dynamically?
    Edited by: P.Ranish on Dec 13, 2012 6:23 AM

    P.Ranish wrote:
    Is there any update for this question ???
    Edited by: P.Ranish on Dec 13, 2012 3:36 AMNo, And there won't be in the future.
    Please stop posting followup's to old threads, if you have a real problem please search the forum first and post a new question with all information
    Roel wrote:
    Try using &P5_RUNNING_TOTAL. or #P5_RUNNING_TOTAL#Just to make it clear - this will only work if page is reloaded after setting the item values dynamically via AJAX

  • Passing values to APEX items from external site

    All,
    Is it possible to pass values to APEX page items from an external web site?
    For example, I have an external web site where users type in a username and password into fields. When they click the 'log-in' button in the external site, I would like to have those values passed to the APEX log-in page. If possible, I would like to have the APEX log-in occur 'invisibly' and the user taken directly to the home page of the app. If that's not possible, it would be nice to simply have the 'user name' and 'password' fields filled in on the APEX side.
    I'm using APEX 3.0.
    Thanks in advance for any help!
    Alex

    Hello Alex,
    >> Is it possible to pass values to APEX page items from an external web site?
    The general answer is yes. You can use the f?p syntax to set the value of any APEX item - http://download-uk.oracle.com/docs/cd/B32472_01/doc/appdev.300/b32471/concept.htm#sthref185 .
    In your specific example, the main question should be is it wise? The mere fact that you are using a login process suggests you have something to protect in your application. The f?p syntax uses a plain text for the items’ value, which means that the user name and password will be completely exposed.
    Regards,
    Arie.

  • 2.2 item values passing w oracle reports

    Since upgrading from 1.6 to 2.2, The url to an oracle report does not pass the item value to the report.. also, it drops the item value and just leaves the &. This was working fine in 1.6...
    This is my link in htmldb:
    http://apps.mytxi.com/reports/rwservlet?report=e:\\prod\\reports\\agg_production.rdf&server=schedserver&destype=cache&desformat=pdf&cmdkey=dbuser1&P18_LOB=&P8_LOB.&p18_tkt_loc=&P8_TKT_LOC.&p18_date99=&P8_DATE99.&p8_draft_approval=&P8_DRAFT_APPROVAL."
    and this is what it does when you call the report:
    http://apps.mytxi.com/reports/rwservlet?report=e:\\prod\\reports\\agg_production.rdf&server=schedserver&destype=cache&desformat=pdf&cmdkey=dbuser1&P18_LOB=&p18_tkt_loc=&p18_date99=&p8_draft_approval=
    any help will be greatly appreciated...
    thanks

    Steve - Try upper-casing each item value expression (&P18_TKT. instead of &p18_tkt.) and see if that fixes it. If it does, then check the setting of Exact Substitutions in the application's attributes. If that is No, set it to Yes. If it was No and you change it to Yes, you should then be able to use the original link you were using with the lower-case expressions. However it you find the setting to be No and upper-casing the expressions doesn't help or if you find the setting to be Yes or you change it to Yes and neither lower-case nor upper-case expressions work, we will have to look into it further. If you do change the setting from No to Yes, you will have to locate all item name expressions in your application that might not have the trailing period and add the period.
    Scott

  • Passing values thru application Item.

    All,
    Ive issue here with Apex4.1.x.
    I created an application item to which a value is set using javascript like (document.getElementById('P135_GLOBAL1').value = '100'; ) executed onclick when a LIST ITEM is clicked to display another page/page2. On the called page2 i want its region title set to ="Something&135_GLOBAL1." and same application item value i want to assign to another hidden item in the called page/page2......any idea is appreciated.

    koloo wrote:
    All,
    Ive issue here with Apex4.1.x.
    I created an application item to which a value is set using javascript like (document.getElementById('P135_GLOBAL1').value = '100'; ) executed onclick when a LIST ITEM is clicked to display another page/page2. Application item values cannot be set in this way: they only exist in session state on the server, not as HTML elements in the page that can be manipulated using JavaScript DOM methods/properties in the browser. (Furthermore, when setting page items in this way, always use the built-in APEX method<tt>$s</tt> APEX method to set values in JavaScript as this contains logic to correctly process APEX item types.)
    To set the value of application items in JavaScript, use a Dynamic Action with a Set Value action, triggered by a Change event on your list item.

  • Spark datagrid item editor font see through

    I am using a default item editor on a spark datagrid.
    When the user attempts to edit the field the old value shows through.
    How do I get rid of this?
    I am using out of the box stuff? Is this a listed bug?
    Code is...
    <s:GridColumn dataField="Actual" headerText="Actual" width="75" editable="true">
                        <s:itemRenderer>
                            <fx:Component>
                                <s:DefaultGridItemRenderer textAlign="right"   background="true" backgroundColor="#FFFFFF" alpha="1.0" color="#000000" />
                            </fx:Component>
                        </s:itemRenderer>
        </s:GridColumn>
    Thanks
    Dan Pride

    Try <s:DefaultGridItemEditor if you are wanting to make it editable.
    here is an example of combobox, but it is similiar ....
    <s:itemEditor>
    <fx:Component>
    <s:ComboBoxGridItemEditor  >
    <s:dataProvider>
    <s:ArrayList>
    <fx:String>Edit</fx:String>
    <fx:String>Read</fx:String>
    </s:ArrayList>
    </s:dataProvider>
    </s:ComboBoxGridItemEditor>
    </fx:Component>
    </s:itemEditor>
    Don

  • Calculating a value from a item after pressing a button

    Hi all
    I would like to calculate the value of an item (highest available value in db +1) using a pl/sql-function after pressing a button. The result depends on an other item on the same page. The value of this item is not known while rendering the page. The result should be inserted in the item before saving/validate all other items from this page.
    Part of SQL-Script for one possibility :
    if :P601_OP = 1 then
    select max(substr(sar_id, 5))+1 into :P601_SAR_ID from sar where substr(sar_id,0,3) = 'ORA;
    end if;
    Thanks for your help
    Michael

    Hi Joe,
    when creating a column link in your report you can pass value from your report columns in this link using the # substitution syntax, e.g. #MYCOLUMN#
    brgds,
    Peter
    Blog: http://www.oracle-and-apex.com
    ApexLib: http://apexlib.oracleapex.info
    BuilderPlugin: http://builderplugin.oracleapex.info
    Work: http://www.click-click.at

  • Funny behavior with Item Editors

    I have a DataGrid which has a column with CheckBoxes (item
    editors), initially they are all unselected (suppose there are 5
    rows), if i click on the 5 of them quickly to change them to
    selected then something funny happens, some of them change to
    selected and then to unselected again. If i do this slowly, then it
    works fine. And the same happens if they are all selected and then
    i quickly click on the 5 of them to unselect them, some of them
    became selected again.
    It is as if Flex wasn't able to process the changes so fast,
    so by the time it is processing a CheckBox's change another one
    changes too and it reverts the first one to its previous state.
    Any idea why this happens? is it a bug, a mistake in my code,
    a normal behavior? what is it?

    Code:
    <mx:DataGrid id="dgcatalogo" width="100%" editable="true"
    height="236" dataProvider="{arrCCostoDisplay}" >
    <mx:columns>
    <mx:DataGridColumn dataField="ccoEstatus"
    headerText="{resource.getString('incluir')}" width="50"
    editable="true" rendererIsEditor="true"
    itemRenderer="renderer.CheckRenderer"
    editorDataField="result"/>
    <mx:DataGridColumn dataField="ccoDescripcion"
    headerText="{resource.getString('descripcion')}" editable="false"
    width="200"/>
    </mx2:columns>
    </mx:DataGrid>
    where CheckRender is:
    <mx:VBox xmlns:mx="
    http://www.adobe.com/2006/mxml"
    horizontalAlign="center">
    <mx:Script>
    <![CDATA[
    // Define a property for returning the new value to the
    cell.
    public var result : Boolean = false;
    ]]>
    </mx:Script>
    <mx:Binding source="editor.selected" destination="result"
    />
    <mx:CheckBox id="editor"
    selected="{data.ccoEstatus}"/>
    </mx:VBox>
    That's the code, and like i said, it behaves funny when you
    select/unselect the checkboxes quickly

  • Unexpected value type for Item Tag Name ; expected System.Single, received

    Hi,
    I am using PCo 2.1 with MII 12.1 to extract values from some PI tags. When I run the query, I get this error -
    Unexpected value type for Item <Tag Name>; expected System.Single, received System.String[Value = Scan Off]
    Can somebody explain what I need to do to get the correct result?
    Regards,
    Chanti.

    To make the service return "whatever is passed", you have to take a step back and realize that there is a little understanding of XML Schema required.
    When using a complexType, which is defined as a sequence, then you are implying an ordered sequence of elements. Default value for the 'minOccurs' attribute is 1. It's also important to understand that there is a difference between minOccurs=0 and nillable="true".
    nillable="true" just means that the name element can carry a null value. If you want the name element to be optional, then you must use the minOccurs=0 and keep the maxOccurs to it's default value of 1. Using an array is just a bad work around. This is for deserialization (XML to JAVA).
    The second part of you problem is on the serialization (or JAVA to XML). When you have a JAVA Bean, there is no way to make the difference between a member's value being null or not set, so it's impossible to decide if you need to send back a nul (xsi:nil="true"), an empty element <ns1:name/> or nothing.
    That said, if you do want to go the XML route, you can use the dataBinding="false" flag in the different WSA command. Instead of converting XML into JAVA, you will have SOAPElement parameters, where you can do all you want (see WS user's guide [1] for details - chapter 16). Note that you have to make sure that the WSDL (your contract) reflect what you are doing on the wire (format of your messages), so that you do not geopardize your interoperability with other toolkit.
    Note that this only applies to literal message formats (use attribute in WSDL), which is your case.
    Hope this helps,
    Eric
    [1] http://download-west.oracle.com/otn_hosted_doc/ias/preview/web.1013/b14434.pdf

  • How to refresh page after selecting value from LOV item , in a tabular form

    Hi ,
    I have a tabular form, which contains 2 items(columns), of type "Select List - named LoV".
    Now, couple of issues here.
    1.
    2nd item(column) in tabular form, that LoV should get populated based user's selection value in first item LoV. So how do i refer to the value, that user selected in first item's LoV? I will have to use this reference in LoV query of my 2nd item ( on this tabular form)
    2.
    How can we refresh the page, when user selectes value in first item ( from LoV). As this is a tabular form, here item type is Select List, we dont have an option to pick item type as Select List with Submit. So problem is that when user selects value for item 1, refresh does not happen and item 2 LoV does not get populated as per user's selection in item 1.
    Please help here. Would be really appreciated.
    Thanks and Regards,
    Rave.

    Thanks Ben and Dan for your responses.
    Ben, your solution helped me with refresh of page, as page got submitted.
    This answers to my 2nd question. However, I still need to know first question, which basically is, how do i refer to the value, that user selected in first item LoV.
    Issue is, I selected the value in first item LoV, it got submitted and page fot refreshed. But after page refresh, first item LoV loses its value that I had selected last time. It does not retain the selected value after refresh.
    I have an unconditional process, that on every submit(refresh) of page, I set my items with their corresponding values. But problem is what do i mention there to refer to this item.
    I looked in view source of my page, this item is referred as f03.
    So i used "apex_application.g_f03", to set this item to its value, in my uncoditional submit process. But it did not work. I tried to refer this item as "f03" in this unconditional submit process. But still it did not help, the selected item loses its value after page refresh(submit).
    Any help here would be really appreciated. Please suggest how do we refer to this item's selected value.
    Thanks and Regards,
    Ravi.

  • How to get a value from one item into another

    How can i get value from one item into another item.
    Ex: I have a report, in there i have check boxes, and when i have checked some rows, and press submitt, a prosses computates it into a item on another page, and a branche redirects to page 3. Then i'm going to use the value in the item into a PL/SQL script in an report to show the submittet items.
    How can i do this?
    Computation script, pages and all that is fixed. But i dont know which PL/SQL statement to use to get th value from the item.

    Hi Fredr1k,
    Use the V() function from pl/sql.
    e.g. V('P3_MY_ITEM')
    will return the value of that page item.
    As long as the pl/sql is called from within the Apex environment.
    Regards
    Michael

  • How can I delete null values from List Item?

    Hi Friends,
    I used List item for field job_Type, I entered values in List item at design time through property pallet. When I run form I will see null values in this List Item.
    How can I remove these null values from the List?
    Best regards,
    Shahzad

    Dear Shahzad,
    It can be removed by adding the following code in the When-new-Form-Instance.
    Set_item_property('List name', required, property_true);
    :block_name.list_name := <put your default value here>; (If you didn't oput the default value, then you will get some problem and the cursor may not navigate away from the list).
    Senthil Alagu .P.

  • Can you calculate multiple text boxes to achieve a total value?  If so how is that done?  I am trying to create a order form where multiple items can be purchased but i would like the values of each item to calculate so I can achieve a total value.

    Can you calculate multiple text boxes to achieve a total value?  If so how is that done?  I am trying to create a order form where multiple items can be purchased but i would like the values of each item to calculate so I can achieve a total value.

    Hi sashby51,
    I've moved your discussion to the PDF Forms forum--the folks who visit this forum regularly should be able to point you in the right direction.
    Best,
    Sara

Maybe you are looking for