Erase columns in DataGrid

greets, long time without doubts
my question is:
i have 2 DataGrids the first one has one fixed column , the second one has 4 fixed columns
i use a button to convert the rows of the DataGrid 1 in columns, then if i delete a row in the DataGrid 1 it must delete the corresponding column in the DataGrid 2
how i can delete the columns of DataGrid 2 in that way???

If you want to delete the content of the column, you must work on the DataGrid's dataProvider.
If you want to remove the column, you can use :
var columnsCollection    :ArrayCollection = new ArrayCollection( yourDataGrid.columns );
columnsCollection.removeItemAt( columnsCollection.getItemIndex( youDataGridColumn ) );
yourDataGrid.columns = columnsCollection.toArray();

Similar Messages

  • How to validate a whole column of DataGrid

    I want to validate a whole column of DataGrid using
    Validator.
    How to do that?

    Thanks. It works! Prima!
    It's a little bit difficult for me to write and understand the English terms correctly, cause I am German.
    I did not recognize, that I had to go to the Library Module!
    Here I repeat Rikk's way in German:
    Im Bibliothek-Modul
    Rasteransicht
    Bilder selektieren
    Im Menufeld Ad-hoc Entwicklung:
    Freistellungsfaktor einstellen: 16:9

  • How to hide blank columns in datagrid?

    Hi,
    I have a datagrid nicely populated with data.
    But I have some colums which are blank (the columns have a
    Header but the rest of its rows are blank).
    I want to hide these columns so that users can't see them.
    Note that the blank columns are not fixed. Sometimes it can
    be that a column is blank but at other times it can be filled.
    So I cannot use... "<... visible=false>
    I need to loop thru the columns and then hide the blank
    columns.
    Anyone has an idea how to code for this loop.
    Thx

    Well..from what i know, the datagrid supports the syntax to
    allow for you to specify the columns explicitly through the
    DataGridColumn. Done like this
    <mx:datagrid>
    <mx:columns>
    <mxdatagridcolumn datafield = "Column 1 name" ..>
    <mxdatagridcolumn datafield = "" ..>
    <mxdatagridcolumn datafield = "" ..>
    </mx:columns>
    </mx:datagrid>
    why dont you specify the columns you want using this. that
    way, if there is no data in the colums, that column just wont show.
    Hope i am understanding you right when you say hide blank
    columns

  • How to hide column of DataGrid

    I am making a web part in which I am using System.Web.UI.WebControls.DataGrid control.
    It's AutoGenerateColumns property is set to TRUE.
    I am trying to hide a column at run time. I have written the following code on this controls ItemCreated event but it only works if I e.Item.Cells[0] and it doesn't work for any other value for e.g. e.Item.Cells[1] and e.Item.Cells[6].
    There are 9 columns in my DataGrid control.
    Code
    protected void grd1_ItemCreated(object sender, DataGridItemEventArgs e)
    { e.Item.Cells[0].Visible = false; //works fine
    e.Item.Cells[1].Visible = false; //gives error e.Item.Cells[2].Visible = false; //gives error
    Error
    Specified argument was out of the range of valid values.
    Parameter name: index
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
    How to hide a particular column?

    Hi Frank,
    You can try something similar to the below in 'RowCreated' event Instead
    protected void gridView_RowCreated(object sender, GridViewRowEventArgs e)
    e.Row.Cells[1].visible =false;
    OR I would say hiding column is not something that is to be done at row level, so you can hide columns outside any of the grid view event after binding.
    e.g.
    gridview1.columns[1].visible=false;
    I am using DataGrid control in which there is no RowCreated event.
    I have tried second approach but it also doesn't work.

  • Rearrange column in Datagrid in Flex

    Hi, i am retrieving data from database using arraycollection to fill in the datagrid with dynamic column header, and the columns are arranger alphabatically depend on the column header title, for my case i want to rearrange the columns depend on specific order, i created another function to rearrange the columns, and its working fine for the first page load but when i change the dropdown entries i get all the columns rearranged but without data only the first column contain data which is [EngName]
    the following is my code
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="init()" layout="vertical"  width="70%" backgroundAlpha="1" backgroundColor="white" xmlns:local="*">
    <mx:WebService id="wsExec" wsdl="http://wfsvc-test/ExecSummaryReport.asmx?WSDL" useProxy="false" showBusyCursor="true">
    <mx:operation name="GetExecSummary2" result="handleExecSummaryResult(event)" fault="handleFault(event)"/>
    </mx:WebService>
    <mx:WebService id="wsAdmin" wsdl="http://wfsvc-test/Admin.asmx?wsdl" useProxy="false" showBusyCursor="true">
    <mx:operation name="SelectDirectorates" result="handleDir(event)" fault="handleFault(event)"/>
    <mx:operation name="SelectSections" result="handleSec(event)" fault="handleFault(event)"/>
    </mx:WebService>
    <mx:Script>
    <![CDATA[
    import mx.controls.dataGridClasses.DataGridColumn;
    import mx.messaging.AbstractConsumer;
    import mx.collections.ArrayCollection;
    import mx.controls.Alert;
    import mx.rpc.events.FaultEvent;
    import mx.rpc.events.ResultEvent;
    [Bindable]
    private var gridData:ArrayCollection;
    [Bindable]
    private var dirData:ArrayCollection;
    [Bindable]
    private var secData:ArrayCollection;
    private function init():void
      wsAdmin.SelectDirectorates();
      var today:Date = new Date();
      today.setDate(1);
      dtFrom.selectedDate =today;
      dtTo.selectedDate = new Date();
    private function handleExecSummaryResult(event:ResultEvent):void
      for each(var objTbl:Object in event.result.Tables)
       gridData = objTbl.Rows as ArrayCollection;
      dg.dataProvider = gridData;
      var columns:Array = dg.columns.sort(orderColumns);
      dg.columns = columns;
      dg.visible = true;
    private function orderColumns(a:DataGridColumn, b:DataGridColumn):int{
       if (a.headerText == "EngName" || b.headerText == "EngName"){
              return -1;
       }else if (a.headerText < b.headerText){
              return -1;
       }else if (a.headerText > b.headerText){
               return 1;
      } else {
        return 0;
    private function handleDir(event:ResultEvent):void
      var dirArr:Array = new Array();
      var defaultItem:Object = new Object();
      defaultItem['data'] = '00';
      defaultItem['label'] = '-- Select Directorate --';
      dirArr.push(defaultItem);
      for each(var objTbl:Object in event.result.Tables)
       for each(var objRow:Object in objTbl.Rows)
        var obj:Object = new Object();
        obj['label'] = objRow['EngDir'];
        obj['data'] = objRow['DirCode'];
        dirArr.push(obj);
      dirData = new ArrayCollection(dirArr);
    private function handleSec(event:ResultEvent):void
      var secArr:Array = new Array();
      var defaultItem:Object = new Object();
      defaultItem['data'] = '00';
      defaultItem['label'] = '-- Select Section --';
      secArr.push(defaultItem);
      for each(var objTbl:Object in event.result.Tables)
       for each(var objRow:Object in objTbl.Rows)
       var obj:Object = new Object();
       obj['label'] = objRow['EngSec'];
       obj['data'] = objRow['SecCode'];
       secArr.push(obj);
      secData = new ArrayCollection(secArr);
    private function handleFault(event:FaultEvent):void
      Alert.show(event+'');
    ]]>
    </mx:Script>
    <mx:Label width="100%" textAlign="center" text="Executive Summary Report" fontSize="24"/>
    <mx:HBox width="100%">
    <mx:HBox width="100%" horizontalAlign="right" verticalAlign="middle" >
    </mx:HBox>
    </mx:HBox>
    <mx:HBox width="100%">
      <mx:Label text="Search: From"/>
      <mx:DateField id="dtFrom" name="n1" formatString="DD/MM/YYYY"/>
      <mx:Label text=" To "/>
      <mx:DateField id="dtTo" name="n1" formatString="DD/MM/YYYY"/>
      <mx:Label text="   Directorate:"/>
      <mx:ComboBox id="ddlDir" dataProvider="{dirData}" width="170">
       <mx:change>
        <![CDATA[
         wsAdmin.SelectSections(ddlDir.selectedItem['data'].toString());
        ]]>
       </mx:change>
      </mx:ComboBox>
      <mx:Label text=" Section:"/>
      <mx:ComboBox id="ddlSec" dataProvider="{secData}" width="170"/>
      <mx:Label text="Status: "/>
       <mx:CheckBox id="chkCompleted" label="Completed" selected="true">
        <mx:click>
         <![CDATA[
          chkCompleted.selected = true;
          chkInProgress.selected = false;
         ]]>
        </mx:click>
       </mx:CheckBox>
       <mx:CheckBox id="chkInProgress" label="In Progress">
        <mx:click>
         <![CDATA[
          chkCompleted.selected = false;
          chkInProgress.selected = true;
         ]]>
        </mx:click>
       </mx:CheckBox>
      <mx:Button label="Show Report">
       <mx:click>
        <![CDATA[
         if(ddlDir.selectedIndex<1 || ddlSec.selectedIndex<1)
          Alert.show('Please select a Directorate & Section');
         }else
          wsExec.GetExecSummary2(ddlDir.selectedItem['data'],ddlSec.selectedItem['data'],chkInProgr ess.selected,dtFrom.selectedDate,dtTo.selectedDate);
        ]]>
       </mx:click>
      </mx:Button>
    </mx:HBox>
    <mx:DataGrid id="dg" width="100%" rowCount="12"  visible="false"/>
    </mx:Application>

    I'm suspicous about how it can return -1 for both A.headerText and
    b.headerText == "EngName"

  • Dynamic columns in datagrid

    Hi,
    I have a datagrid with a dataprovider.
    And,I am trying to set the number of columns and column
    headerText values of that Datagrid based on the values from an
    array.
    Any suggestions on how we can do this or does anybody has
    already worked on this?
    Those suggestions would of very great help to me.

    Assume that your colum information is contained in the Array
    columnInfo which is not your dataProvider. Assume "dg" is the ID of
    your DataGrid control.
    var columns:Array = new Array(); // this will hold the
    DataGridColumns
    for(var c:int=0; c < columnInfo.length; c++) {
    var col:DataGridColumn = new DataGridColumn();
    col.headerText = columnInfo[c].headerText; // or whatever
    holds the header text
    col.dataField = columnInfo[c].dataField; // or what holds the
    name of the field in the dataProvider
    columns.push(col);
    dg.columns = columns; // columns now added to the
    DataGrid.

  • Click event for single column in DataGrid

    I can add an event listener to a DataGrid of type
    ListEvent.ITEM_CLICK, which is triggered when the user clicks any
    part of an entire row in a DataGrid. I want to trigger a click
    event for just one column. I only want to run a function when the
    user clicks in just the first column of the DataGrid, and not run
    trigger the event if they click in any other column. Any help would
    be much appreciated.

    Accessing the event.target returns the entire DataGrid, not
    the DataGridColum. Any way to get just the DataGrid column?

  • Aligning a Column in DataGrid

    I have a DataGrid that shows product information. And one
    column is a 'Price' and the client wants JUST that 'Price' column
    to be aligned to the right.
    Is this possible? if yes, then any example?
    Thanks,

    You can also set the lockedColumnCount property in the mx:DataGrid as well:
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
        <mx:DataGrid id="dg3" lockedColumnCount="1" horizontalScrollPolicy="auto" width="300">
            <mx:dataProvider>
                <mx:ArrayCollection>
                    <mx:Object c1="1" c2="one" c3="ONE" c4="OnE" c5="The quick brown" />
                    <mx:Object c1="2" c2="two" c3="TWO" c4="tWo" c5="Fox jumps over" />
                    <mx:Object c1="3" c2="three" c3="THREE" c4="ThReE" c5="The lazy dog" />
                </mx:ArrayCollection>
            </mx:dataProvider>
        </mx:DataGrid>
    </mx:Application>
    Peter

  • ResourceGantt Chart - showing the task column in datagrid or tooltip, help?

    Hi all,
    I managed to create a resource gantt chart, but now I would like to display the task in both datagrid, i.e. the left panel with columns and in the tooltip. How can I force the view of this task name or project? At the moment, only the resource name, start date, end date, % of completion show up. Any help please?
    thanks
    Edited by: mzeid on Mar 20, 2012 1:31 PM

    Luca,
    I think this is what you want:
    The expressions are as follows:
    Scores Table
    Medi Column: =AVERAGE(B2:G2)
    Passing Column: =IF(H≥6, H, "")
    Failing Column:  =IF(H≤6, H, "")
    Pie Chart Data Table:
    Pass Column: =COUNTIF(Scores::H, ">=6")
    Fail Column: =COUNTIF(Scores::H, "<6")
    The Bar Chart is a 2D Stacked Bar Chart
    Hope this is what you were looking for. Glad to explain further if necessary.
    Jerry

  • Adding Dynamic column to datagrid at the begining of datagrid

    Hello friends,
    There is one datagrid which is static. and i m adding one dynamic column. it is get added to the end of the static datagrid
    but I want to add dynamic column at the begning of the datagrid can anybody help me on this.
    Thanking you,
    Regards,
    gajanan

    Thanks to everybody.
    finally i got the things to work using following code.
    private  function SwapGridColumns (DG:DataGrid, Col1:Number, Col2:Number):void
                    var i:Number; // Counter
                    var DP:ArrayCollection =ArrayCollection( DG.dataProvider);     //DataProvider
                    var Widths:Array = new Array ();     // the widths of the columns
                    var Columns:Array = new Array ();    // the column names
                    var Visibility:Array = new Array (); // visibility of columns
                    var HRenderer:Array = new Array ();   // Header Renderer of columns
                    var IRenderer:Array = new Array();
                    var datastore:Array = new Array ();
                    var Editable:Array = new Array();
                    var DFields:Array=new Array();
                    var Sortable:Array = new Array();
                    for (i = 0; i<DG.columns.length; i++)
                        if (i == Col1)
                            Columns.push(DG.columns[Col2].headerText);
                            Widths.push(DG.columns[Col2].width);
                            Visibility.push(DG.columns[Col2].visible);
                            HRenderer.push(DG.columns[Col2].headerRenderer);
                            IRenderer.push(DG.columns[Col2].itemRenderer);
                            Editable.push(DG.columns[Col2].editable);
                            Sortable.push(DG.columns[Col2].sortable);
                            DFields.push(DG.columns[Col2].dataField);
                        else if (i == Col2)
                            Columns.push(DG.columns[Col1].headerText);
                            Widths.push(DG.columns[Col1].width);
                            Visibility.push(DG.columns[Col1].visible);
                            HRenderer.push(DG.columns[Col1].headerRenderer);
                            IRenderer.push(DG.columns[Col1].itemRenderer);
                            Editable.push(DG.columns[Col1].editable);
                            Sortable.push(DG.columns[Col1].sortable);
                            DFields.push(DG.columns[Col1].dataField);
                        else
                            Columns.push(DG.columns[i].headerText);
                            Widths.push(DG.columns[i].width);
                            HRenderer.push(DG.columns[i].headerRenderer);
                            IRenderer.push(DG.columns[i].itemRenderer);
                            Editable.push(DG.columns[i].editable);
                            Sortable.push(DG.columns[i].sortable);
                            DFields.push(DG.columns[i].dataField);
                    // Reset the widths
                    var col:Array
                    for (i = 0; i < Columns.length; i++)
                        var DGC:DataGridColumn = new DataGridColumn(Columns[i]);
                        DGC.width = Widths[i];
                        DGC.visible = Visibility[i];
                        DGC.headerRenderer = HRenderer[i];
                        DGC.itemRenderer = IRenderer[i];
                        DGC.dataField=DFields[i];
                        DGC.sortable=Sortable[i];
                        DGC.editable=Editable[i];
                        datastore.push(DGC);
                    DG.columns=datastore;
                    // Load DP
                    DG.dataProvider = DP;
    Regards,
    gajanan

  • How create grouped column in DataGrid ?

    Hi all,
         I can create grouped column in AdvancedDataGrid. So in DataGrid, how I create grouped column ?
    Thanks.

    I have a problem that no anyone can help me to now. Sometime, I think that it's bug of ADG.
    My goal same as from http://blogs.adobe.com/aharui/BlinkWhenChanged/dg.swf . But if I use ADG and with a scroll ! And when scroll up or down background color change not right.
    It's a big problem ! Yep, when I use ADG, I can create group columns but ADG, I can't !
    Is there any ways for me?

  • How Auto Fit column in DataGrid

    Is it possible to set autofit in DataGrid column ?
    Without auto fit the users must resize the table every
    time.

    Please Check this example
    http://www.flex4ex.com/?p=24

  • Sorting Columns in Datagrid

    Developing in Flash, AS3.
    I have a datagrid that uses a custom cellrenderer class to allow me to use a combobox. I have an invisible column that holds the value returned by the cellrenderer when the combobox value is changed. BUT sorting is wonky. Since what really lives in the combobox column individual cells is an object, it never really sorts properly. Is there a way to fire a sorting event to the column that holds the real value?
    Thanks in advance!

    Thank you very much for your quick reply. Would you mind providing an example that will work with a combobox?
    Right now, I'm using this bit of code, just to track which cel is being interacted with:
              public function gridItemSelected(e:ListEvent):void {
                   trace ("***");
                   trace( "Row Index: " + e.rowIndex);
                   trace( "Column Index: " + e.columnIndex);
                   var colName:String  =  e.target.columns[e.columnIndex].dataField;
                   trace( "Column Field Name: " +colName);
                   trace( "Cell data: " +e.item[colName]);
                   trace("***");
    which traces out something like this:
    Row Index: 0
    Column Index: 0
    Column Field Name: cname
    Cell data: [object Object],[object Object],[object Object],[object Object],[object Object]

  • Sum columns in datagrid

    Hi All,
    I have a DG with multiple columns (Numbers), the values are coming from an array collection.
    What is the best way to sum couple columns? like
    Column01 + Column02 = ColumnTotal
    I try using a labelFuction in the column like:
    private function sumColumns(item:Object, col:DataGridColumn):String {
       var tempNumber:Number = parseFloat(item.column01) + parseFloat(item.column02);
       return tempNumber.toString();
    But the result doesn't reflect in the arraycollection. Should I create the column with values at the time of received the results?
    If I do this, when I change the value in any of the columns 01 or 02 it doesn't change the total.
    Thanks for your help.
    Johnny

    Yes, immediately after u receive the result create another property in the and assign the sum of two columns to it and then assign it to the datagrids data provider. the property that you create will be mapped to the column which shows the sum. if you are using label function to get the sum you can se a lot of calls med to the label function even when you scroll, this is all unnecessary memory hog.

  • Format columns of Datagrid to TimeFormat

    Hello I have a data grid which I populated dynamically using
    array.
    I have 1 of the column (its header is mytime).
    But the time is displayed as : Thu Jan 1 20:03
    I want my time format to be as such : 20:03 AM/PM
    Please help me how can I format the whole column of a
    datagrid.
    Thx

    <mx:Script>
    <![CDATA[
    import mx.controls.dataGridClasses.DataGridColumn;
    import mx.formatters.NumberFormatter;
    import mx.formatters.DateFormatter;
    protected function MyRenderer(row:Object,
    column:DataGridColumn):String{
    return nf.format(row[column.dataField ]);
    protected function dateFormat(dateItem:Object,
    column:DataGridColumn):String
    return publishDate.format(dateItem[column.dataField]);
    ]]>
    </mx:Script>
    <mx:Style source="style.css" />
    <mx:DateFormatter id="publishDate"
    formatString="MM/DD/YYYY JJ:NN:SS" />
    <mx:NumberFormatter id="nf"
    precision="2"
    rounding="up"
    decimalSeparatorTo="."
    thousandsSeparatorTo=","
    useThousandsSeparator="true"
    useNegativeSign="true"/>

Maybe you are looking for

  • Delete the file from AL11

    hi all, how to delete file from application server(al11)? apart from using EPS_DELETE_FILE and writing a code  any other go to acheive it regards venkat

  • Purchase Order Header Status tab

    Hello. I have a problem-question. In some POs in header status tab, the quantity is missing and only the amount is displayed. Why is that? thank you!

  • Run Object command syntax in Lookout

    In my application I want to move the CSV files saved in Lookout folder to another place in the network when a button is pressed. The command line for the run object is: "cmd /c move /y C:\Program Files\National Instruments\Lookout 5.1\2004\*.* \\leo-

  • How to set the DVD Folder Path?

    Hello, had a quick question regarding the folder path variable when accessing DVD video files. When authoring, Director seems to automatically add a hardcoded file Name to the cast member properties, as well as a folder path to the DVD member propert

  • How to find indirect evaluation wage types exist in the system

    Hi Experts, How can we find indirect evaluation wage types exist in the system ( including customer wage type). Thanks in Advance. Regards, IFF