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.

Similar Messages

  • 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().

  • Importing From Flat File with Dynamic Columns

    HI
    I am using ssis 2008,i have folder in which I have Four(4) “.txt” files each file will have 2 columns(ID, NAME). I loaded 4
    files in one destination, but today I receive one more “.txt” file here we have 3 columns (ID, NAME, JOB) how can I get a message new column will receive in source. And how can I create in extra column in my destination table dynamically …please help me

    Hi Sasidhar,
    You need a Script Task to read the names and number of columns in the first row of the flat file each time and store it in a variable, then create a staging table dynamically based on this variable and modify the destination table definition if one ore more
    new columns need to be added, and then use the staging table to load the destination table. I am afraid there is no available working script for your scenario, and you need some .NET coding experience to achieve your goal. Here is an example you can refer
    to:
    http://www.citagus.com/citagus/blog/importing-from-flat-file-with-dynamic-columns/ 
    Regards,
    Mike Yin
    TechNet Community Support

  • Creating Query with dynamic columns to show results

    Hi experts,
    I need to know how to create a query with dynamic columns. Meaning, I don't want to create a query with fixed columns representing the 12 periods of the fiscal year to show me actuals as the fiscal year proceeds.
    For example, if I am currently in the middle of period 3 (March) of a fiscal year, when I execute the query, I need it to automatically only show me the 'Actuals' for periods 1 and 2, without seeing the columns from periods 3 to 12 showing blank.
    Then when I am in the middle period 5 (May) the query should ONLY show me the columns for periods 1 to 4 'Actuals', no results should be shown for periods 5 to 12 yet, and I don't want to even see blank columns for period 6 to 12.
    How do I define my columns, to achieve this.
    Maximum points will be awarded.
    Thanks Everyone.

    Hi Josh,
    I'm having a little difficuluty understanding what should be included in my restricted key figures.
    The time characteristics that I have available to use are:
    0FISCPER3 (posting period)
    0FISCYEAR (fiscal year), currently using SAP EXIT to default current fiscal year.
    0FISCVARNT (fiscal year variant).
    In addition, I have the following characteristics available to be used in the columns:
    Value type (10)
    version (currently I'm using variable for it)
    Currency type (020)
    Currency (USD).
    Can you explain what my restricted key figure should be based on and how it should look.
    I tried to create a restircted key figure using 0AMOUNT, and 0FISCPER3. For 0FISCPER3  I created a range from 1 to previous period (using SAP EXIT that supplied previous period).I also had value type, version, currency type, and currency included in that restricted key figure.Then when I tried to drag 0FISCPER3 under the restricted key figure once again, it wouldn't let me, probably because I've already used 0FISCPER3 in the restricted key figure.
    Please let me know if my explanation is not clear.
    Your step by step help would be great.
    Thanks
    Edited by: Ehab Mansour on Sep 23, 2008 2:40 PM

  • DataTable with dynamic columns

    Does somebody have an example of how to code a h:dataTable with dynamic columns? I have seen hints about how to do it in these two articles:
    http://forum.java.sun.com/thread.jspa?forumID=427&threadID=5218508
    http://forum.java.sun.com/thread.jspa?threadID=577589&messageID=2909047
    but a complete working example would be really helpful.
    I think the key is understanding the "binding" parameter to h:dataTable but I'm having a hard time understanding it. Thanks.

    I found it here:
    http://balusc.blogspot.com/2006/06/using-datatables.html#PopulateDatatable

  • Logic to upload file with dynamic columns

    hi
    in my requirement i hav given to add logic to upload file with dynamic columns so that this upload program can be reused.
    this way the program is flexible, irrespective of the number of columns in the file.
    can any one explain this?
    and let me know what actually i hav to do.

    Check the program and the dynamic column is in the col_pos internal table and in the routines get_structure onwards.
    https://www.sdn.sap.com/irj/sdn/wiki?path=/display/scm/dynamic%2bstructures%2band%2bcomponents
    cheers
    Aveek

  • Difficult to achive the report layout with dynamic column names

    I have a report layout as below.
    So here the column names are dynamic.And each fixed row group has different calculations. I have a date parameter. If I select July 2013, then I need to show data from July 2012 to July 2013 with Columns(Jul-12, Aug-12...Jul-13). How to achive below layout
    with dynamic columns?

    Hi Sarayu_CM,
    According to your description, you want to filter the records of prior year based on only one parameter selection. Right?
    In this scenario, we can create two parameters. The first one is for user to select. The second parameter is based on the first parameter selection. We don't need to specify Available Values for the second parameter, but we should use expression to specify
    Default Values based on the first parameter selection. Use the expression below:
    =DateAdd("m",-12,FormatDateTime(Parameters!param1.Value))
    Then we just need to apply a filter on the matrix/dataset to get the records which the date is between values in these two parameters.
    If you have any question, please feel free to ask.
    Best Regards,
    Simon Hou

  • 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

  • Problem with dynamic column in SBWP

    Hi Friends,
    In SWL1 I have created two attributes with header as "CANCELLED" and " DESCRIPTION" for a particular task.But my SBWP is still showing columns as "Dynamic column" for the workitems of that task.
    Please help me on this.
    Thanks.
    Dilip

    Hi Dilip,
    The column headings will only appear in the task-specific view. In other words, by default the headers will be generic because you can have mixed tasks in the worklist, and column 1 can be a date for one task and a company name for another.
    The user needs to expand the tree on the left hand side and navigate to the "Approve Purchase Order" (or whatever) node to show only items of that task, then column headers should show up.
    Regards,
    Mike

  • Problem with dynamic columns in smartforms.

    Dear SDN Experts,
    I have a requirement in smartforms for dynamic columns.
    i have used template with 10 columns, So from these 10 columns,Columns may vary monthly MIN 2 to MAX 10 depending on
    readings with them  for that month.
    i cannot fix column headings also,Because headings also changes dynamically.
    So Problem is if there is no data in columns,Columns is displayng empty.
    For EX: In this month i have 2 columns data remaining all columns is displaying empty boxes.
    Please suggest me a solution  is this posible in smartforms if i use table also.
    <removed by moderator>
    Regrds,
    MNR
    Edited by: Thomas Zloch on Sep 11, 2011 3:50 PM

    Hi friend,
    See the link below it is having the solution of hiding the columns in smart forms
    Hide table columns in smart form?
    Create a table to display your values with 12 col and hide the columns based on the idea provided in the link above.
    I think this will solve your issue if you still have queries please revert back to me i will help you.
    Thanks,
    Sri Hari

  • GoNav function with dynamic columns 10g

    Hi,
    I have a report with a dashboard prompt that dynamic change the report column. The result of this prompt is set into a presentation variable @{dimension}.
    Now I want to use the GoNav function on the column that dynamically changes.
    The data format for this column should be:
    @[html]"<font class="Nav" onclick=\"javaScript:GoNav(event, '/users/Administrator/Test', 'Department', 'Department_name' ,'"@"','_self');\">"@"".
    But this syntax only works for the column Department.Department_name. If the prompt on the dashboard is changed to another column the navigate link doesn't work anymore.
    Is there a solution to make this work so that also the column can be set dynamically for the navigation?

    I have a report with a dashboard prompt that dynamic change the report column. The result of this prompt is set into a presentation variable @{dimension}.
    Now I want to use the GoNav function on the column that dynamically changes.
    The data format for this column should be:
    @[html]"<font class="Nav" onclick=\"javaScript:GoNav(event, '/users/Administrator/Test', 'Department', 'Department_name' ,'"@"','_self');\">"@"".
    But this syntax only works for the column Department.Department_name. If the prompt on the dashboard is changed to another column the navigate link doesn't work anymore.
    As per your comments above you are using Column selector kind of functionality using a Dashboard prompt and in your GO nav you are taking column Department that's way it is working for that column only , if you change the Column in Dashboard prompt also still GO nav point to Department column only...make the GO NAV to take dynamic columns..
    I am not sure whether we can pass presentation variable .....with my knowledge its not..use GO URL instead of GO NAV

  • DataGrid with dynamic comboboxes

    I need to design a dataGrid with comboboxes in one column. These comboboxes should all have different dataProviders based on a value from column 1. What would a general approach be?
    Thanks

    The renderer's data property is the data for the entire row so you can get the column1 data and assign the combobox's dataprovider accordingly.
    Alex Harui
    Flex SDK Developer
    Adobe Systems Inc.
    Blog: http://blogs.adobe.com/aharui

  • Form with dynamic Column Names

    Hello,
    I am using "Form with report on table" and I would like to make use of dynamic column names labels that are derived from another table (sql). I am stuck on how to do this, any advice?

    Hi FourEyes;
    Try using this.
    Select Col1, Col2, Col3
    into :P1_Field1, :P1_Field2, :P1_Field3
    from Your_Table
    Where (your conditions);

  • Pivot Table with Dynamic Columns and Headers

    Hello,
    I'm trying to pivot a table of data where the column headers will be dynamic.  While I know how to pivot the table to get what I want how will I be able to pick up the table column header from the Pivot to display in the report?
    For example:
    Unpivoted data is Employee Code, Branch Code, Problem Code, # of Problems.
    There is many records for a given Employee and Branch that I want to pivot so the Column headers are the Problem Codes and the data below is the SUM(num_problems) for that Problem.
    So the data may look like this for Tech Bob, Branch NY.
    Problem = LEAK, Num_problem = 5
    Problem = DAMAGE, Num_problem = 2
    Problem = OTHER, Num_problem = 3
    Which problem codes may appear is unknown but selecting the DISTINCT(problem) across all techs gives me the column headings to use.
    So if I pivot this data, I get this Row:
    Tech = Bob, Branch = NY, DAMAGE = 2, LEAK = 5, OTHER = 3
    So first can SSRS handle having dynamic columns?  Only Tech and Branch are known and the remaining columns are dynamic based on how many Problems they worked on.
    Second, how can I set the column heading in my Tablix to be the Problem Code?
    Sherry

    You just need to use a  matrix container
    Use EmployeeCode and BranchCode for row group
    ProblemCode as column group and SUM([No Of Problems]) as the data expression and it will generate the columns for you based on ProblemCode values automatically.
    See an example here
    Sample Matrix
    Please Mark This As Answer if it solved your issue
    Please Vote This As Helpful if it helps to solve your issue
    Visakh
    My MSDN Page
    My Personal Blog
    My Facebook Page

  • How to create a report with dynamic columns

    Hi all,
    I am using Apex 4.0 with Oracle 10g
    I am creating a report and I need to display columns dynamically based on the item values.
    example:
    I have a table employee with columns name, designation, sal
    In the report page i have a select list with designations and when I select a designation from the select list,
    I need to display the names of the employees horizontally,
    like each name as a new column in the report with that particular designation. and same has to continue when I select different designations.
    Can some one help me how we can do that.
    I appreciate your answer
    Thanks,
    Rik

    Essentially you want to write a pl/sql function which returns a varchar2 string. The contents of the string must be a valid sql statement.
    Once you have done this, you need to add a report region as type sql report and you will have the option of writing it as a query or as a function returning query. Choose function returning query and enter in the function call.
    Note your function must be valid, and must be executable by your apex parsing schema.
    example:
    create or replace
    function test_report(   p1_tablename       in varchar2)
    return varchar2
    is
    v_query varchar2(4000);
    begin
    v_query  :=
    'SELECT * from '||p_tablename;
    return v_query;
    end test_report;Edited by: Keith Jamieson on Aug 15, 2011 4:50 PM

Maybe you are looking for

  • Can't open Itunes on Windows 7

    When I click Itunes Icon, nothing happens.  I've tried a few things.  Restored the PC.  Uninstalled Itunes and Quicktime.  Reinstalled both, uupdated to the latest Itunes 11.01 and still nothing.  I want to install I07 but have to back up my iphone 1

  • How to update data when primary key is set through for update cursor

    Dear friends, I have tried to update data in the table through forms using cursor for update and i have given the plsql i have used please help me where i do mistake. DECLARE CURSOR EMP IS SELECT EMPNO,EMPNAME,FATHERNAME,COMMUNITY,SEX,BILLUNIT,BIRTHD

  • Using mobile as router

    hi i'm just wondering if its possible to connect my laptop too my main pc through mobile phone. i have connected my mobile to laptop using usb cable too nokia suite (runs fine) and have a usb bluetooth dongle which is also conected to my mobile at sa

  • PS CS5 -crash using brush + grass tool

    New Mac running Snow Leopard and CS5. 2560 x 1920 resolution on an Apple Cinema display. As soon as the user selects the brush tool and then the grass tool and starts filling up the screen, it crashes. It crashes every time like this. All updates hav

  • ABAP API + Workflow

    Hi All, How can we access or trigger MDM Workflow using ABAP API. Please help... Regards, Nikhil