DYnamic data grid through ActionScript

Hi...
I want to create a Data grid dynamically during runtime based
on some input through action script.
It will be helpful if some one can post me an example of how
to creat the data grid dynamically and use all its common
properties.
Regards

Please read the Flex 2 on the DataGrid class for the details,
but here's the gist:
var grid:DataGrid = new DataGrid();
grid.dataProvider = someCollection; // same as
dataProvider="{someCollection}" in MXML
// set other properties here
grid.setStyle( "alternateItemColors", [0xff0000,0x00ff00]);
// same as alternateItemColors="[0xff0000,0x00ff00]" in MXML
// set other styles here
var columns:Array = new Array();
var col:DataGridColumn = new DataGridColumn();
col.headerText = "Test";
col.dataField = "someField";
columns.push(col);
// create more columns
grid.columns = columns; // same as <mx:columns> in MXML
addChild(grid); // vital - without this your grid will not be
visible.

Similar Messages

  • How to add a Hyperlink to open popup in dynamic data grid?

    Hi,
    I am a new bie in FLEX, the question which I am asking might be very easy but i am not able to find solution to it. Please can some one help me.
    I am creating a data grid dynamically using action script code now I want to add a Hyper link to couple of columns in a row. How can I do it in FLex?
    Thanks.

    HI Prashant,
    Thanks for the reply.
    This is what I am currently doing right now:
    for 
    (var i:int=0; i<colNameList.length;i++) { 
    var headerText:String = colNameList[i] + ""; 
    callSellGridCol = cols[i];
    callSellGridCol.headerText = headerText;
    if(headerText != null && headerText == "RIC"){
    var myRenderer : ClassFactory = new ClassFactory(com.db.carving.synthetic.dma.view.UrlLinkRenderer);
    In My Renderer class :
    public 
    class UrlLinkRenderer extends LinkButton{
     public var clickFunction:Function; 
    public function UrlLinkRenderer() { 
    super();}
    // Override the set method for the data property. 
    override public function set data(value:Object):void{
    super.data = value; 
    if (value != null){
    label = value[DataGridListData(listData).dataField];
    else{
    label =
    super.invalidateDisplayList();}
    Now what i want is to add a new Event Listner to this object so that I can click it?
    In your suggestion you said:
                         var classFacory:ClassFactory = new ClassFactory(LinkRenderer); // here LinkRenderer is any mxml/ as file Having Link Button defined.
    Where should be the Link button defined??
    Thanks.

  • Dynamic loading tree and data grid

    Hi All,
    I new to java as well as JSF. I am very impressed with the jsf and Sun Java Creator IDE. I made a sample project.
    Now I want to load tree and data grid with dynamic values how can I achieve this.
    Please help to find out some examples.
    Also I need to know who I can use SOAP call using JSF.
    Thanks
    CSCS

    To dynamically load a Basic Table (ui:table) from a database, see http://developers.sun.com/prodtech/javatools/jscreator/learning/tutorials/2/databoundcomponents.html
    To dynamically load a Basic Table from other sources of data that are loaded into an array or such, see http://blogs.sun.com/roller/page/divas?entry=table_component_sample_project
    To dynamically CREATE a Basic Table, see http://developers.sun.com/prodtech/javatools/jscreator/reference/tips/2/createTableDynamically.html and http://developers.sun.com/prodtech/javatools/jscreator/reference/tips/2/add_component_to_table.html
    To dynamically create an HTML table on the fly, see section 7.5 in Chapter 7 of the Field Guide at http://developers.sun.com/prodtech/javatools/jscreator/learning/bookshelf/index.html
    To dynamically create a tree, see Dynamic Tree example at http://developers.sun.com/prodtech/javatools/jscreator/reference/index.jsp.
    A tutorial for dynamically creating a tree from a database is work in progress.
    Hope this helps,
    Chris

  • Data Grid Dynamic Cell Colors

    I would like to create a Data Grid where the individual cell
    colors change based on the number in the cell.
    For example, numbers between 0 and 1 would be green, between
    1 and 2 would be yellow, and between 3 and 4 would be red.
    I am wondering if this is even possible, or if I am going to
    have to find another solution other than the data grid component.
    Not looking for a complete answer (but I'd be happy to have
    one!) but any pointing in the right direction would be great.
    I have a lot of data and coloring the cells by hand is not an
    option. I don't even know if I can change individual cell colors in
    the data grid- if it isn't possible I'd be willing to change the
    text color instead.
    Any suggestions?
    Thanks!

    Example query:
    select cust.*
    , case when credit_limit > 5000 then 'red' else 'green' end as bg_color
    from (
    select
    CUSTOMER_ID,
    CUST_FIRST_NAME,
    round(dbms_random.value(1000,9000)) as CREDIT_LIMIT
    from #OWNER#.DEMO_CUSTOMERS
    ) custIn the Column Definition of CREDIT_LIMIT, set the HTML-Expression to &lt;div style="background-color:#BG_COLOR#">#CREDIT_LIMIT#&lt;/div>
    See result : http://apex.oracle.com/pls/apex/f?p=41715:3
    You could also construct the whole html in the SQL but I like to divide logic (SQL) and UI.
    Another option could be to create a Dynamic Action (After Refresh of the report region) and create a combination of a nifty selector and piece of JavaScript, but I guess this is easier.

  • Adding a dynamic summary row for a spark data grid

    i'm looking for a solution for a spark data grid.
    by clicking on a row it will become larger and will show under the original row a some kind of a summary text with no realtion to columns.
    is there a summary row option for a spark datagrid that can shown by clicking on the row?

    Why would you need to make this part of the DataGrid? Just create some kind of view and bind it's data to the selectedItem of the DataGrid.
    *edit*
    Ohhhh, I see that you want it to display under the item. I believe you can do what you need in the skin, but I haven't had a chance to use the spark DataGrid yet so I can't say for sure. I know it has a feature to skin the selection, so I'm sure you can use that to do what you need.

  • Dynamic Data in Xcelsius Dashboard via ExcelXML Map?

    Hello,
    I am trying to create a dashboard with a grid with a variable number of rows and columns. The data is given to Xcelsius through an Excel XML map i.e. I have given an XML source to an Excel file and then have imported that excel file into Xcelsius.
    I am able to see dynamic data changes within the pre-specified dimensions (i.e. from the first import). For example, if I have a 4X5 grid and change the text in the first row and first column, then Xcelsius will reflect this. However if I add an additional row with data in the xml file, I am not able to see this, even if I resize the the grid so that it has room at the bottom to be filled in.
    Does anybody have any experience with this/can anyone point me to specific articles? I have followed the instructions given in the Tech Tips article, but this only applies to data within a specific structure, while I want to change the structure itself.
    In short, is it possible to do dynamic structures in Xcelsius?
    Thanks.
    Regards,
    Anjana Dasu

    Hi,
    Please go to Data>Connections>Excel XMl maps under usage tab please check if you have set the options "Refresh on load" or "refresh every".
    If not, please select the refresh option and save the xlf file and then try to create a dashboard again.
    Cheers,
    Anshul

  • XmlDataProvider .... is gone completely in my Xaml file. Why? How many different ways to deal with xml data source through WPF

    I followed a procedure described in a book.
    1. insert "Inventory.xml" file to a project "WpfXmlDataBinding" .
    2. add the XML data source through the data panel of "blend for 2013", named it "InventoryXmlDataStore" and store it in the current document.
    3. dragged and droppped the nodes from the Data panel onto the artboard.
    Then I checked my Xaml file against the one provided by the book
    Xaml file by the book:
    <Window.Resources>
    <!-- This part is missing in my xaml file --><XmlDataProvider x:Key="InventoryDataSource"
    Source="\Inventory.xml"
    d:IsDataSource="True"/>
    <!-- This part is missing in my xaml file -->
    <DataTemplate x:Key="ProductTemplate">
    <StackPanel>
    <TextBlock Text="{Binding XPath=@ProductID}"/>
    <TextBlock Text="{Binding XPath=Cost}"/>
    <TextBlock Text="{Binding XPath=Description}"/>
    <CheckBox IsChecked="{Binding XPath=HotItem}"/>
    <TextBlock Text="{Binding XPath=Name}"/>
    </StackPanel>
    </DataTemplate>
    </Window.Resources>
    <Grid>
    <ListBox HorizontalAlignment="Left"
    ItemTemplate="{DynamicResource ProductTemplate}"
    ItemsSource="{Binding XPath=/Inventory/Product}"
    Margin="89,65,0,77" Width="200"/>
    </Grid>
    my Xaml file:
    <Window x:Class="WpfXmlDataBinding.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="MainWindow" Height="922" Width="874">
    <Window.Resources>
    <DataTemplate x:Key="ProductTemplate">
    <StackPanel>
    <TextBlock Text="{Binding XPath=@ProductID}"/>
    <TextBlock Text="{Binding XPath=Cost}"/>
    <TextBlock Text="{Binding XPath=Description}"/>
    <CheckBox IsChecked="{Binding XPath=HotItem}"/>
    <TextBlock Text="{Binding XPath=Name}"/>
    </StackPanel>
    </DataTemplate>
    </Window.Resources>
    <Grid DataContext="{Binding Source={StaticResource InventoryXmlDataStore}}">
    <ListBox HorizontalAlignment="Left" Height="370"
    ItemTemplate="{DynamicResource ProductTemplate}"
    ItemsSource="{Binding XPath=/Inventory/Product}"
    Margin="65,55,0,0" VerticalAlignment="Top" Width="270"/>     
        </Grid>
    </Window>
    All looks quite the same except the <XmlDataProvider ....> part under <Window.Resources>, which is gone completely in my Xaml file.
    1, Why?
    2, How many different ways to deal with xml data source through WPF?
    Thanks, guys.
    (ps My "WpfXmlDataBinding" runs without problem through.)

    Never do yourself down Richard.
    Leave that to other people.
    It's quite common for smart developers to think they're not as good as they are.
    I coach a fair bit and it's a surprisingly common feeling.
    And to repeat.
    Never use anything ends .. provider.  They're for trivial demo apps.  Transform xml into objects and use them.  Write it back as xml.  Preferably, use a database.
    You want to read a little mvvm theory first.
    http://en.wikipedia.org/wiki/Model_View_ViewModel
    Whatever you do, don't read Josh Smiths explanation.  I used to recommend it but it confuses the heck out newbies. Leave that until later.
    Laurent Bugnion did a great presentation at mix10.  Unfortunately that doesn't seem to be working on the MS site, but I have a copy.  Download and watch:
    http://1drv.ms/1IYxl3z
    I'm writing an article at the moment which is aimed at beginners.
    http://social.technet.microsoft.com/wiki/contents/articles/30564.wpf-uneventful-mvvm.aspx
    The sample is just a collection of techniques really.
    I have a sample which involves no real data but is intended to illustrate some aspects of how viewmodels "do stuff" and how you use datatemplates to generate UI.
    I can't remember if I recommended it previously to you:
    https://gallery.technet.microsoft.com/WPF-Dialler-simulator-d782db17
    And I have working samples which are aimed at illustrating line of business architecture.  This is an incomplete step by step series but I  think more than enough to chew on once you've done the previous stuff.
    http://social.technet.microsoft.com/wiki/contents/articles/28209.wpf-entity-framework-mvvm-walk-through-1.aspx
    The write up for step2 is work in progress.
    https://gallery.technet.microsoft.com/WPF-Entity-Framework-MVVM-78cdc204
    Hope that helps.
    Recent Technet articles: Property List Editing;
    Dynamic XAML

  • Site refreshed from dynamic data.

    I have a site stubb out that has multiple accordian canvases
    each containing a tree. In my header area I have a combo box that
    give you a list of clients. When you select a new client, I want to
    reload all the trees in each accordian cavas with that clients
    data.
    I have played around and am able to do this setting a click
    event on buttons that will call the send method on my HTTPService
    object, and it appears to work, but I dont have a lot of control
    over the data, and my implementation is pretty "clunky".... I am
    looking for high level suggestions as to a best practice to
    dynamically load data via http calls and refresh page data.
    I am not very well versed in Actionscript, but am wondering
    if I should be building a majority of the site through actionscript
    objects instead of mxml. This will be a much bigger learning curve
    for me, but I am assuming it will give me a much more flexible
    site.
    Please let me know if you have any comments or resources that
    describe what I am trying to do... Thanks, Mike

    hi
    Working with flex involves learning at least 2 languages, the
    flex language both mxml and actionscript and usint it in a
    combination, but to have a dynamic site you also need to know a
    backend language like C# or VB.NEt, PHP , also is useful to know a
    little about Databases, because if you want a dynamic site it will
    involve data for sure and where do youget data from? A database.
    You will build much of your site in actionscript that is a certain,
    because mxml is very good but itself is not sufficent to do
    everything you want.

  • How to set  headerText in DataGrids through ActionScript

    Any help or suggestions with this appreciated. I'm populating
    a datagrid control in Flex 2 with dynamically data. The number of
    columns and column names aren't fixed. The column data itself is
    just raw values; no field names or other elements to identify what
    the column header should be.
    So when the data provider updates I need to be able to
    tweak/add the headerText for the columns. How do I access this
    setting through actionscript? I see many examples for defining
    <mx.DataGridcolumn> and properties, but I can't really do it
    that statically in advance; I don't know the column count or type
    of columns until runtime.
    Is it possible to access the headerText property with
    something like dataGridID.column[0].DataGridColumn.headerText = ""?
    This is what I'm looking for, the ability to iterate through and
    set the headerText, but I haven't found the magic incantation.
    Thanks!

    You can access the columns through the dataGrid.columns array
    property.
    Get a reference to that array from the DG into a variable,
    modify the column elements as desired through that var, then
    re-assign the var to the dg.columns property. So you are close:
    var aColumns:Array = dataGridID.columns;
    var dgc:DataGridColumn = aColumns[1];
    dgc.headerText = "this is column 1";
    dataGridID.columns = aColumns; //this step is required!
    Tracy
    Tracy

  • Using htp.p for print dynamic data in apex region make my page slow?

    Hi, everyone!!! My name is Rafael, and...
    I search in the web and in this forum but i can´t find a answer for my doubt.
    Using the procedure htp.p for print dynamic data in apex region through on demand process , this will leave my webpage slow to load when the user access?
    Example:
    For build a menu in my webpage, it´s read a function in the database that returns variable string, so by a demand process this string is obtain and print in a web page using htp.p.
    I notice that this practice causes slow to load the data on the page.
    This is it...
    If someone help me, thanks...
    bye and Happy new Year!!!
    Edited by: user9518141 on 26/12/2009 17:19

    Hi,
    Try commenting out the function call and print some sample text in the htp.p like htp.p('Hello world..');
    I think the function call is probably taking a lot of time .. not htp.p.
    I have used htp.p to print out values dynamically in a lot of situations and have not ever come across any performance issues.It could be a problem with the function you are calling.
    Thanks,
    Rajesh.

  • Value from data grid not showing in workspace

    Hi everyone.
    I've entered value in data grid that i maid in Planning for one member. It looks like there is no velue for that member. What needs to be done to recognize new source?
    Member is set on Store and is used in some formulas in Dynamic Calc members.
    Thx.

    Maybe it is an implied share, is it is an only child, set the member to "never share", refresh and try again.
    Cheers
    John
    http://john-goodwin.blogspot.com/

  • Data Grid Display child Class data

    Hi,
       I have  2 Action Script class binded to remote java class
    Class 1
    package hmil.setup.model
    import hmil.com.general.model.Employee;
    [Bindable]
    [RemoteClass(alias="hmil.setup.model.Area")]
    public class Area
    public function Area()
    public var ARMST_AREA_ID:int;
    public var ARMST_CMPN_NO:String;
    public var ARMST_CORP_NO:String;
    public var ARMST_SCTN_TYPE:String;
    public var ARMST_CRTE_USR_NO:String;
    public var ARMST_CRTE_TIME:Date;
    public var ARMST_UPDT_USR_NO:String
    public var ARMST_UPDT_TIME:Date;
    public var ARMST_DLR_LIST:ArrayCollection;
    public var ARMST_EMP:Employee;
    Class 2
    package hmil.com.general.model
    [Bindable]
    [RemoteClass(alias="hmil.com.general.model.Employee")]
    public class Employee
    public function Employee()
    public var EPMST_ID:Number;
    public var EPMST_CMPN_NO:String;
    public var EPMST_CORP_NO:String;
    public var EPMST_EMP_NO:String;
    public var EPMST_DLR_NO:String;
    public var EPMST_EMP_NAME:String;
    When the remote java method returns  a list of Area object through Blaze DS  this list can be assiged as data to the Data Grid
    The DataGridColumn   dataField can be mapped to the column name and it displays properly
    <mx:DataGridColumn  dataField="ARMST_AREA_ID" headerText="Id"/>
    But lets say I wanted to display the child value  (ARMST_EMP.EPMST_ID )   in the Data Grid 
    Since the sever returns the Parent Java Object  which contains the related Employee as inner Object.
    The Objetcs are deserialized to AS class objects.
    But how to display the  child columns in data grid.
    If i give the data field as ARMST_EMP  it is displayed as Object. but if i mention the datafield as ARMST_EMP.EPMST_ID, it does not display anything.
    please  let me know how to display the child object in datagrid
    Thanks

    Hi Mugunda, did you ever find out how to do this?

  • How to put an image in a data grid in Flex Builder 2

    Hi All,
    I need to populate a data grid with some text data received
    from a web service and, in a particular column of the datagrid, I
    have to put an image depending of a specific data returned me by
    the web service.
    It seems that there is the possibility to add an image in
    data grid column with the cellRenderer properties, but this
    property is available only for ActionScript 3.
    I'm developing an application in Flex Builder 2 that run
    ActionScript 2 and cellRenderer properties is not available. Is it
    right?
    If no, I will can use this cellRenderer properties in my
    application. Please, can you show me an example?
    If yes, there is a way to insert an image in datagridcolumn
    with ActionScript 2?
    Thank you very much
    Regards

    Flex Builder 2 uses Actionscript 3.
    You will need to write a renderer for for this column.
    There are a lot of examples of datagrids with images in them.
    here is one from the livedocs
    http://livedocs.adobe.com/flex/201/html/wwhelp/wwhimpl/common/html/wwhelp.htm?context=Live Docs_Book_Parts&file=cellrenderer_072_28.html

  • How to avoid blinking / moving of rows in a data grid when you restore the scroll positions

    By Default when an update is made on a data grid, it scrolls to top row. To avoid this when we save the vertical and horizontal scroll
    positions and restore the scroll positions after the update, it causes a blink in the grid (or moving / jumping) of rows. Is there a way to
    avoid this jumping of rows?
    In JavaScript this can be achieved by overriding the scrollToTop / OnLoad methods of datagrid to directly scroll to current scroll
    positions instead of top row. Is there a way to achieve similar feature in flex / actionscript?

    I am calling validateNow().. Also, using verticalScrollPosition to restore the scroller as in the link that you posted.. Reposition is working fine, But the bug filed is regarding BLINKING / JUMPING when this happens (i.e. this blinking is caused because after datagrid edit, during reload the scroller tries to move to  the top by default, then it repositions itself to current edited row as the verticalScrollPosition property is overridden ).. I have to get rid of this blinking.
    In Javascript it is dealt by overriding OnLoad method of datagrid to directly scroll to current scroll position instead of top row during reload so that there is no blinking.
    http://www.sencha.com/forum/showthread.php?13898-Is-there-any-way-to-keep-scroll-position- of-Grid-on-load
    Is there a way to achieve similar feature in flex?
    I am not sure what flex datagrid method to override.. Theres no method like load? What is the datagrid method that is called by default during reload (after datagrid edit) that causes the scroller to go to top?

  • How to add a checkbox coulmn to my Data Grid row?

    Dear All ,
    I have a Data Grid which have lets says 6 columns. I want to add anew column which allow the user to select it or not. Meaning if the user select the box a hack will be shown.
    I want to you this coz I have a function which send an email to the user if the line (Invoice line) if selected. Now if there is more than one invoice (Line) I want the user to first select the checkbok and send press the send function button.
    Later on I will create a loop in the Send function which will only send mails if the line check box is checked.
    Would you please help me :)
    Ps: I am using ligth switch 2008   (C#)
    Thanks,
    Zayed

    Hello Zayed
    I would recommend that you read through this brilliant article by
    Paul van Bladel here or even look at a post on
    this forum by Sven Elm. I have looked at and followed these in the past and it works perfectly.
    If you found this post helpful, please mark it as helpful. If by some chance I answered the question, please mark the question as answered. That way you will help more people like me :)

Maybe you are looking for

  • Is Bridge part of CS3?

    Probably a dumb question...but where does Bridge come into play with Photoshop and what is it's main function? Is Bridge part of CS3 or not? I have Photoshop Elements and will upgrading to CS3 when the new quarter starts so I've been reading up and a

  • Im planing to buy a second hand ipad 2 any tots and tips? thanks in advancee

    Im planing to buy a second hand ipad 2wifi  any tots and tips? thank inadvanse Johan

  • Using my Apple TV box elsewhere

    Can I use my Apple TV box in someone else's home whilst I stay there for a couple of days?

  • Parser.setErrorStream in SAX Parser

    The setErrorStream method is not provided in the SAX API. It would be very helpful and nice to have this there as in case of schema validation, if the structure of the document is not according to the XSD, and there are lots of errors, ArrayIndexOutO

  • How can update my class instance at runtime?

    What would happen if at runtime I update a class file? Will the JVM know to use that instead? How can I use the updated class at runtime? Who can give me an example? thanks all!