Datagrid with calculated column

Hi all,
Does anyone know how or where I might learn to create a
calculated field in a DataGrid?
Flex 2

There are several ways, depending on what you want.
Easiest is to use a labelFunction() instead of a dataField.
A custom item renderer is another way.
Yet a third way is to have your dataProvider be a collection
of custom value objects, one of which is the calculated value.
Tracy

Similar Messages

  • DataGrid with dynamic columns & renderers

    I'm developing using Flash Builder 4 & Flex SDK 4.1.
    I need to manage very dynamic DataGrid components and keep their definitions, which are all part of a complex item renderer of an Offers list.
    The objects structure is simplified as follows -
    Data: Model --> Offers ArrayCollection --> Offer VO --> DataGrid data ArrayCollection & DataGrid columns Array
    View: List --> Offer Item Renderer --> DataGrid
    1. Since the DataGrid's columns property accepts only an Array (not ArrayCollection), it seems like Data Binding for defining the columns is very problematic.
    I tried to bind it to the source property of an ArrayCollection that would keep my columns definitions, but it didn't really work (mainly header display bugs).
    What is the recommended way to keep the dynamic columns definition of a DataGrid?
    2. Each column can have a set of dynamic properties, so I created a "mutant" - Column VO that extends DataGridColumn and got a dynamic properties ArrayCollection on it.
    The columns got a custom header renderer that includes an icon when there are properties.
    The header renderers got 4 main states (NotSelectedWithProperties, SelectedWithProperties, NotSelectedWithoutProperties & SelectedWithoutProperties).
    However, the header renderer area seems a bit buggy when maintaning dynamic columns.
    Any thoughts on the subject?
    3. Anyway, I ended up recreating the DataGrid's columns Array very often (copying the columns definition on the offer's item renderer's dataChange event handler).
    Note that the dynamic properties can be edited when the column is selected and I copy their values from the view back to the model when entering the state NotSelectedWithProperties.
    This feels way too complicated and I really try to keep it simple, inspite of the required complexity.
    Does anyone have better ideas?
    4. In some cases the column's item renderer should also be modified into another DataGrid (grid-in-grid).
    I used the MXDataGridItemRenderer with a DataGrid and included an ArrayCollection for the "newValue" returned by the editor.
    (I use RendererIsEditor=true and on updateComplete populate that variable with the DataGrid's dataProvider contents)
    When needed, I loop though the data objects of the parent DataGrid and populate the related field with an ArrayCollection of key-value objects that are displayed on the internal DataGrid.
    After adding this feature I encounter very strange bugs -
    a. After editing the grid-in-grid values and changing the column's state (selecting & deselecting), I get the following exception:
    ArgumentError. Error #2025: The supplied DisplayObject must be a child of the caller.
    at flash.display::DisplayObjectContainer/setChildIndex()
    at mx.core::UIComponent/setChildIndex().......6993....
    All I could find about this is that it might be related to some context error or something, but I'm really stuck on this one.
    b. Sometimes another column might copy value from one row to another, running over the previous value.
    I'm not sure exactly what sequence of actions causes this behavior, but it's related to that itemRenderer for sure.
    c. Switching places with a column that uses the grid item renderer (headerShift) causes a stak overflow of StyleManager that tried to get style from the DataGridItemRenderer. This one I just found out, but couldn't reproduce a second time... strange!
    I'm pretty sure this caused another problem that I don't remember at the moment.
    The bottom line is that there got to be a better way to implement this feature within this already-complicated environment.
    Maybe I'm doing something very wrong here...
    Please advice and thanks for reading all this.

    Update on item 4a -
    This was a major issue (the main reason for opening this thread really) and I managed to resolve it!
    As part of my application, I override the default DataGrid behavior for column selection (headerRelease event).
    Instead of sorting, I change the column's header looks and define it as Selected (for showing its dynamic properties and enable its deletion).
    At first I did this by setting styles, but the look didn't refresh unless I created a new instance of the header renderer.
    Later I changed thi behavior to work with states, but I left the new header renderer instance creation commands and those lines created all the mess!
    Conclusion -
    If you define a custom header renderer for your datagrid column and then a custom item renderer, don't create a new instance of your header renderer!
    It would still be nice to get some response for the other issues I raised.
    Thanks and have a nice week.

  • Sync to SharePoint Workspace with Calculated columns

    I have a document library (in a SharePoint 2010 site) with a calculated column that will not Sync to the SharePoint Workspace 2010.  Once I remove the calculated column, it syncs fine. 
    The calculated column displays an image in the document library depending on the state:
    ="<center>"&IF(State="Not Started","<img src='http://rcssportal.co.riverside.ca.us/sites/teammate/PublishingImages/NotStartedIcon.png' border='0'/>",IF(State="In Progress","<img src='http://rcssportal.co.riverside.ca.us/sites/teammate/PublishingImages/InProgressIcon.png'
    border='0'/>",IF(State="Prepared","<img src='http://rcssportal.co.riverside.ca.us/sites/teammate/PublishingImages/PreparedIcon.png' border='0'/>",IF(State="Reviewed","<img src='http://rcssportal.co.riverside.ca.us/sites/teammate/PublishingImages/ReviewedIcon.png'
    border='0'/>",IF(State="Edited Since Reviewed","<img src='http://rcssportal.co.riverside.ca.us/sites/teammate/PublishingImages/EditedSinceReviewIcon.png' border='0'/>",IF(State="Conflict","<img src='http://rcssportal.co.riverside.ca.us/sites/teammate/PublishingImages/ConflictIcon.png'
    border='0'/>","")))&"</center>")))

    Hello Thomas,
    Maybe you are experiencing this issue:
    http://office.microsoft.com/en-us/sharepoint-workspace-help/why-is-this-sharepoint-list-not-synchronizing-all-item-fields-or-view-updates-HA010388327.aspx?CTT=1
    As far as I know it is not a limitation of SharePoint Workspace 2010:
    http://office.microsoft.com/en-us/sharepoint-foundation-help/synchronize-sharepoint-content-with-sharepoint-workspace-HA101854201.aspx#_Toc263166752
    - Dennis | Netherlands | Blog |
    Twitter

  • Spark DataGrid with Dynamic Column Width

    Lets suppose I have a Spark Datagrid with no explicit typicalItem. When the Datagrid is initialized, the column widths are calcualted correctly based on the contents of the dataprovider. However if I add/remove an item from the dataprovider, or modify the one of the objects in the dataprovider, the column widths never update to reflect the change. Is the the correct behavior for a DataGrid? If so, is there any method I can call to force the DataGrid to recalculate and redraw the column widths?

    When Spark DataGrid doesn't have a typicalItem, it uses the first dataProvider item as the typicalItem.  If you change that, the DataGrid won't pick it up immediately. You can invalidate the current typicalItem using dataGrid.invalidateTypicalItem().

  • Dynamic DataGrid with Preferred columns

    Hi all,
    I want to populate a dynamic DataGrid with User Preferred
    columns (ex : EmpId,First Name and Phone). Each time columns may
    change based on User Selection in Preferences Page so columns
    should not hard code. I'm able to see data for EmpId, First Name
    but I want to see the Inner tag data of "Phone" as a Field.
    Sample XML ....
    <emp>
    <empId>1002</empId>
    <firstName>Smith</firstName>
    <lastName>John</lastName>
    <address>
    <city>Ohio>
    <phone>433-234-322</phone>
    <zip>60003</zip>
    </address>
    </emp>
    Thanks.

    To display nested data, you must use a labelFunction. I have
    several labelFunction examples on cflex.net.
    You can assign a function reference to the column's
    labelFunction property in the column generation code.
    Tracy

  • Indexing running forever with calculated columns

    I want to use an InfoCube as a source in Business Objects Explorer. So I defined a universe on top of the InfoCube using Information design tool along some calculated columns (similar to calculated key figures in BEx query).
    The indexing used to work fine with the default keyfigures in the InfoCube. I started using the newly created calculated columns and now the indexing runs for hours and does not complete until I remove the calculated columns. Is this a performance issue, if yes please do let me know how to fix it.
    Thank you

    Hi Pavan,
    Thanks for the reply. I will try doing that and will get back to yo.
    The relational data foundation of this universe was defined over an InfoCube and it did not have any primary keys for dimension tables (master and text) nor the foreign keys (fact table). Does this also affect the performance of explorer?

  • Help with calculated column formula- combine strings and convert to date

    In my list (SharePoint Server 2013) I have:
    'Invoiced Month' column, type of choice (strings with names of months- January, February, March..., December)
    'Year' column, single line of text (e.g. 2012, 2013, 2014)
    1. I need to create a calculated column which will return combined value of the columns above, but in DATE format e.g. 'Sep-2013' or '01-Sep-2013'.
    I then use that newly created calculated column to do this: http://iwillsharemypoint.blogspot.in/2012/03/sharepoint-list-view-of-current-month.html
    I am rubbish with formulas, can I have some help with my problem please?

    Hi,
    Use the formula, I have tested by creating Months column with choice, Year column as numeric and Calculated column as DateTime returned.
    =DATE(Year,IF([Months]="January", 1,IF([Months]="February",2,IF([Months]="March",3,IF([Months]="April",4,IF([Months]="May",5,IF([Months]="June",6,IF([Months]="July",7,IF([Months]="August",8,IF([Months]="September",9,IF([Months]="October",10,IF([Months]="November",11,12))))))))))),1)
    Before applying the formula few things need to be noted.
    DATE(YEAR, MONTH,DAY) will accepts three parameters all should be type numeric(integer).
    Create the Year column of type numeric
    Create the calculated column of type "DateTime" to return as date
    Please mark it answered, if your problem resolved or helpful.

  • (Advanced)DataGrid with selectable columns

    Hello -
    I'm trying to make a Flex (Advanced)DataGrid component with some mechanism where the user can toggle the visibility of the columns.  I've crudely implemented this by reading in the columns into the right-click menu, and when a column name is selected here, the visibility is toggled.  It works, but it's not the most elegant solution.
    Specifically, I'm trying to emulate the "datagrid" that Mozilla Thunderbird uses to display emails.  Here is an image:
    In the upper right, there is an icon over the scroll bar.  If there is no scrollbar, the icon remains in the same place.  When clicking the icon, it opens up a menu that shows all the possible columns, with the visible ones having a check mark next to them, like this:
    Also, the scroll bar always appears under this button, never "pushing" it over into it's own column.
    I'd like to re-create this in Flex.  I believe the menu part and creating a column with a button headerRendered is easy enough.  But I can't figure out how (if at all possible) to do this with the scrollbar, because the scrollbar always seems to be "its own column".  Any ideas or help would be appreciated.  Thank you.
      - Ian

    This blog post seems to answer your question:
    http://blog.flexgeek.in/2007/06/tips-tricks-adding-a-combobox-to-a-datagrid-header-as-head errenderer/
    http://omalraj.com/2009/06/flex-datagrid-header-with-a-combobox-filter/
    http://franto.com/custom-header-in-datagrid-part-2/
    http://blogs.adobe.com/aharui/2007/03/thinking_about_item_renderers_1.html
    If this post answers your question or helps, please mark it as such. Thanks!
    http://www.stardustsystems.com
    Adobe Flex Development and Support Services

  • Write back option with calculated column

    Hi,
    We are trying to use write back option to update some records in our database. We've followed the steps of this blog http://oraclebizint.wordpress.com/2007/09/20/oracle-bi-ee-101332-write-back-option-budgetingplanning/ and we got it running without problems.
    The thing is that we particulary need is to store values that arent a "direct" user input. We are calculating the column through a formula and enabling it for write back, but if there's no interaction with that edit field, changes are not commited to database.
    As we read in Presentation Services Administration Guide (http://download.oracle.com/docs/cd/E10415_01/doc/bi.1013/b31766.pdf) at page 91
    +"If the user *types a value in an editable field* and clicks the write back button, then the++
    +application reads the write back template to get the appropriate insert or update SQL command".+
    So our question is ¿is it strictly necessary user interaction (in terms of typing values in the write back field) to commit changes to database?. ¿Is there any way without user typing of storing values from BI to db?
    We think user typing is mandatory but we have to be completely sure about this because we have to provide a serious and right answer to our customer.
    Thank you very much in advance for any help provided.
    Regards

    There has to be a user interaction - i.e. typing something. You can't just update the DB with some value you calculate.
    Cheers,
    Christi@n

  • Problem with calculated column, everything inc. NULLs appear

    Good morning,
    This one is tough.
    I have a dimension Category (with categories: Fruits, Vegies, Canned, etc.). And in my fact table I have field Expense. Then I decided to create calculated fields like "Fruits Expense" -
    CASE WHEN Dim."Category" = 'Fruits' THEN Fact.Expenses "."Expenses $ CY" END
    There're 2 problems:
    A) if the field Category isn't dropped in Answers there're many NULLS (all Exp values which don't belong to 'Fruits')
    B) If Category isn't there, there're even more NULLs - which don't look good at all - there're too many empty values
    Of course, it's possible to train users to use filters (is not null), etc. - but then it's really not what OBIEE is good at.
    Can someone suggest a better approach?
    I proposed in the beggining to create fields in the DB like "Expense Fruits" - but ut was deemed too complicated on ETL side.
    Thank you and have a wonderful OBIEE day
    UPD: OK, I want to rephrase it and make it easier. Except for using "is not null" filter- is there any other way to supress NULL values? I'm getting 12 empty ones and 1 i need. Is there anything I could do in order to supress showing NULL values by default. Thanks
    Message was edited by:
    wildmight
    Message was edited by:
    wildmight

    Thank you Nilanshu! Where have you been! I'm already seeing quite a few useful contributions. I'll try to go ahead and test your suggestions and I'll report what I've found.
    P.S> It works like a charm. Thank you
    Message was edited by:
    wildmight

  • Advanced datagrid with grouped columns and grouped rows

    hello every body, plz need your experience help. 'cause Im so new using FLEX
    I have an XML (like an XML data type) something like this
    <Table>
      <Rows>
        <cAgencia>F0002</cAgencia>
        <cAgNombre>SanBorja</cAgNombre>
        <cTVentanilla>V0002</cTVentanilla>
        <dTVNombre>Plataforma</dTVNombre>
        <TcksEnEspera>20</TcksEnEspera>
        <VentsEnAtencion>50</VentsEnAtencion>
      </Rows>
      <Rows>
         <cAgencia>F0003</cAgencia>
         <cAgNombre>Miraflores</cAgNombre>
         <cTVentanilla>V0002</cTVentanilla>
         <dTVNombre>Plataforma</dTVNombre>
         <TcksEnEspera>30</TcksEnEspera>
         <VentsEnAtencion>40</VentsEnAtencion>
       </Rows>
      <Rows>
         <cAgencia>F0002</cAgencia>
         <cAgNombre>SanBorja</cAgNombre>
         <cTVentanilla>V0003</cTVentanilla>
         <dTVNombre>Caja</dTVNombre>
         <TcksEnEspera>55</TcksEnEspera>
         <VentsEnAtencion>25</VentsEnAtencion>
       </Rows>
       ...... (continue)
    </Table>
    so, I need to make a table (I guess with advancedDataGrid) something like this
    as you can see,   I have to group them by columns and Rows.  I have found a "mx:groupedColumns" that maybe could help me , but I couldn't find something like "mx:groupedRows".
    The grid may be dynamic,   for example if I have another XML node like:
      <Rows>
         <cAgencia>F0004</cAgencia>
         <cAgNombre>SanMiguel</cAgNombre>
         <cTVentanilla>V0002</cTVentanilla>
         <dTVNombre>Plataforma</dTVNombre>
         <TcksEnEspera>15</TcksEnEspera>
         <VentsEnAtencion>52</VentsEnAtencion>
       </Rows>
    the grid may add a ROW and in the column of plataforma add the data: 15 and 52, so the grid may be something like this:
    as you can see, the grid may add rows and columns in depends of the count of XML data.
    plz help.
    thanks, regards  from Lima, Peru.
    JS

    any help ????????? I found OLAPDataGrid .....   I was thinking to send all the data into a bidimensional Array , then pass the data of my bidimensionalArray to  OLAPDataGrid ...  but I'n not sure if Flex is able to do it  .... 
    the really serious problem is the special ROW I must use ...
    regards
    JS

  • DataGrid with Image column rendering problem

    Hi,
    I'm having trouble in getting images displayed on a datagrid
    column. If I scroll down and then scroll up the scrollbar, the
    images are rendering fine. The source of the image is Bitmap which
    is generated at run time. Any idea how to solve this problem? Any
    help is greatly appreciated.
    Thanks,
    Jeesmon
    My component code is pasted below
    "Attach Code"
    <?xml version="1.0" encoding="utf-8"?>
    <mx:DataGrid xmlns:mx="
    http://www.adobe.com/2006/mxml"
    creationComplete="init()" dataProvider="{cardDataProvider}">
    <mx:Script>
    <![CDATA[
    import mx.core.UIComponent;
    import
    org.eclipse.higgins.cardselector.filters.CustomDropShadowFilter;
    import mx.collections.ArrayCollection;
    import mx.controls.Image;
    import org.eclipse.higgins.cardselector.icard.Card;
    [Bindable]
    private var cardDataProvider:ArrayCollection;
    private var _cards:Array;
    public function get cards():Object {
    return this._cards;
    public function set cards(value:Object):void {
    this._cards = value as Array;
    if(this._cards != null && this._cards.length > 0)
    buildDataProviderArray();
    private function buildDataProviderArray():void {
    var dataArray:ArrayCollection = new ArrayCollection();
    for(var i:int = 0; i<this._cards.length; i++) {
    var card:Card = this._cards
    dataArray.addItem(card);
    this.cardDataProvider = dataArray;
    private function init():void {
    this.styleName = "CardsBox";
    this.width = 200;
    this.rowHeight = 120;
    this.headerHeight = 0;
    this.liveScrolling = true;
    this.filters = [new CustomDropShadowFilter(0x333322, 55,
    2).getInstance()];
    ]]>
    </mx:Script>
    <mx:columns>
    <mx:DataGridColumn sortable="false" editable="false"
    resizable="false">
    <mx:itemRenderer>
    <mx:Component>
    <mx:VBox width="100%" height="100%" paddingLeft="5"
    paddingRight="5" paddingTop="5" paddingBottom="0"
    verticalGap="0">
    <mx:Script>
    <![CDATA[
    import mx.controls.Alert;
    private function getBitmap(value:*) : DisplayObject
    var result:DisplayObject;
    var loader:Loader = Loader(Image(value).getChildAt(0));
    if(loader.contentLoaderInfo.childAllowsParent)
    if(loader.content is Bitmap)
    var bitmap:Bitmap = Bitmap(loader.content);
    result = new
    Bitmap(bitmap.bitmapData,bitmap.pixelSnapping,bitmap.smoothing);
    return result;
    ]]>
    </mx:Script>
    <mx:Image source="{getBitmap(data.getImage())}"
    height="80" width="120" styleName="CardsBoxImage" />
    <mx:Label text="{data.getName()}"
    styleName="CardsBoxLabel" width="100%" />
    </mx:VBox>
    </mx:Component>
    </mx:itemRenderer>
    </mx:DataGridColumn>
    </mx:columns>
    </mx:DataGrid>

    I solved the issue by adding creationComplete event handler
    for the image in the datagrid column
    <mx:Image source="{data.getImage()}" height="80"
    width="120" styleName="CardsBoxImage"
    creationComplete="event.target.source =
    getBitmap(event.target.source)" />

  • How to combine looping column with calculated column

    Dear Gurus,
    I have a report that contains number of sale items in each plant. And plant (0PLANT) is a master data. I have to calculate Accumulate Total as below:
         Plant                         
    Date     Mall 6     Pinklao     Siam     Mini L/P     Total     Acc. Total
    1     135,260     186,170     103,833     145,636     570,899     570,899
    2     32,043     22,772     29,587     19,098     103,500     674,399
    3     49,477     48,919     20,206     23,587     142,189     816,588
    4     33,937     32,399     30,520     30,710     127,566     944,154
    In the column section, I have put the Quantity under Key Figure Structure and put Plant upper the it, so I get the result as below
         Plant                    
    Date     Mall 6     Pinklao     Siam     Mini L/P     Total
    1     135,260     186,170     103,833     145,636     570,899
    2     32,043     22,772     29,587     19,098     103,500
    3     49,477     48,919     20,206     23,587     142,189
    4     33,937     32,399     30,520     30,710     127,566
    I have no idea how can I put the Acc. Total to the report. Please suggest me for this issue. I'm so new for BW.
    Thanks in advance
    Edited by: Sukanya Nawnaung on Apr 24, 2008 6:04 AM

    Not knowing your tables I do not know the answer as it is not obvious from your scripts what the join between the two data sets would be??
    If you can tell me that then you can easily combine the two with an in-line view or using the new WITH... syntax.
    Otherwise, I see that the only difference between the two joins is;-
    1st WHERE DR_ACC = DECODE(DR_ACC,*'TXN'*,DR_ACC)
    2nd WHERE DR_ACC = DECODE(DR_ACC,*'OFS'*,DR_ACC)
    If you make this (don't understand the need for the decode, why is it here?!); -
    DR_ACC in ('TXN','OFS')
    And then use a case statement if you need to seperate out your two pairs of columns; -
    case when DR_ACC = 'TXN' then TXN_BRANCH else null end as "Transaction Branch" (repeat principal for other 3 columns)
    case when DR_ACC = 'OFS' then A.OFS_BRANCH else null end as "Offset Branch", (repeat principal for other 3 columns)
    Make sense?
    regards,
    Robert.

  • Problem with calculating column total

    Hi All,
    I am using Oracle Jdeveloper 11g Release 2.
    I want to show the sum of salary in application. I have the following step to do this.
    *1.*
    I have written the following code in EmployeesViewImpl.java class:
    public Number getSalarySubtotal() {
    if (salarySubtotal == null) {
    salarySubtotal = new Number(0);
    RowSetIterator rsi = this.createRowSetIterator(null);
    while (rsi.hasNext()) {
    Row r = rsi.next();
    Number salaryTotal = (Number)r.getAttribute("Salary");
    if (salaryTotal != null) {
    salarySubtotal = salarySubtotal.add(salaryTotal);
    rsi.closeRowSetIterator();
    return salarySubtotal;
    *2.*
    I have also exposed this method as client interface on view object.
    *3.*
    I have also create a method binding on the page where I want on consume this method.
    *4.*
    The output text has the following expression: #{bindings.getSalarySubtotal.inputValue}.
    When I run the page, it is showing nothing.
    I don't know what is wrong with this approach.
    Any help will be highly appreciated.
    Thanks in advance
    Regards
    Bilal

    Are you trying to calculate the total salaries of employees? If that is the case you need this method at the Dept level.
    Have a look at this video:
    http://download.oracle.com/otn_hosted_doc/jdeveloper/11gdemos/ADF_Insider_Essentials/ImplementingTotals/ImplementingTotals.html?utm_source=dlvr.it&utm_medium=twitter

  • Trouble with DataGrid's last column width

    I have a datagrid with thirty columns.
    When I use the mouse to drag the window and resize its size,the last column width becomes more and more wide,and the previous column width is squeezed small.
    If anybody else came accross the same problem,can you share your solution?
    Thanks,
    April

    If horizontalScrollPolicy=”off” then there is an attempt to fit all columns within the width of the DG while respecting minWidth of the columns.  Make sure the minWidths allow the columns you want to shrink can shrink.
    However, there is still a chance of round-off error.  I think the only solution may be to set the width of each column as you want it on a resize event from the DG.

Maybe you are looking for

  • Using apple tv to connect mac book air to tv

    Does anyone know if it is possible to use the apple tv to display something from a macbook air on to my tv? Or does the apple tv only display objects from itunes? if so, what cords would have to be purchased in order to do this?

  • Exchange Rate Difference in FS10N

    Hi guru, In FS10N (Display Account Balance), we have a foreign currency USD for this G/L account, and our local currency is HKD and until the year end, the balance of USD currency show '0', but the HKD balance show '7397.38' is there anyway to make b

  • HT204074 Is "Deauthorize All" my only option for Computer Authorizations?

    According to the support pages I have read, I should be able to "Manage Devices" on the Account Information page. But I only have "Deauthorize All" as an option. I'm I missing something? I'm I not looking in the right place? Is "Deauthorize All" my o

  • SD2 files with Quicktime Windows XP

    I have a SD2 file I need to play. I have tried to play it through Quicktime but I get the error message "Error -39 end-of-file-was-reached" Does anyone know what the problem is or is there any other program I can use?

  • LDAP with Microsoft Outlook

    Hi everybody. I would like to know how could I specify in Microsoft Outlook the base for a search. In Microsoft Outlook Express there is an option to specify this base when configuring the access but I don�t know how to do it in Microsoft Outlook. Th