# Datagrid Problem

**URL:** <https://forum.kirupa.com/t/datagrid-problem/306180>\
**Category:** flash\
**Created:** [March 10, 2010, 9:59pm UTC](https://forum.kirupa.com/t/datagrid-problem/306180 "2010-03-10T21:59:58Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alpha\_Remex](https://avatars.discourse-cdn.com/v4/letter/a/779978/32.png) [@Alpha\_Remex](https://forum.kirupa.com/u/Alpha_Remex)\
**Post date:** [March 10, 2010, 9:59pm UTC](https://forum.kirupa.com/t/datagrid-problem/306180/1 "2010-03-10T21:59:58Z")

</div>

Hello all - I am new to using this DataGrid control and I am having trouble getting this to work the way I want to…

It seems that most tutorials want you to add a row at a time, but I want to add a column of data at a time.

The first thing I am doing is creating the attribute column:

```auto

_dataGrid = new DataGrid();
                    _dataGrid.y = 166;
                    _dataGrid.height = 405;
                    _dataGrid.mask = _mainMask;
                    _dataGrid.resizableColumns = true;
                    _dataGrid.setRendererStyle("textFormat", museoFormat);                
                    _dataGrid.alpha = 0;
                    _dataGrid.addColumn("Attributes");
                    
                    for each(var att:XML in _attributeDatabase.*) {
                        if(att.hidden.toString() == "no") {
                            _dataGrid.addItem({Attributes:att.title.toString()});
                        }
                    }
                    
                    _dataGrid.height = _dataGrid.rowCount * _dataGrid.rowHeight;
                    _dataGrid.x = (602 - (_dataGrid.width/2));

```

Next, based on the selected button I add a corresponding column:

```auto

var columnLabel:String = _selectionHeader.text + " " + e.currentTarget.cName.text;
                
                
                TweenLite.to(cb.checkMask, .2, {x:0});
                _dataGrid.addColumn(columnLabel);
                
                
                for each(var lob:XML in _mainDatabase.*) {
                    if(lob.@id.toLowerCase() == _selectionHeader.text) {
                        for each(var config in lob.*) {
                            if(config.name.toLowerCase() == e.currentTarget.cName.text.toLowerCase()) {
                                var i:uint = 0
                                for each(var attrib:XML in config.*) {
                                    var item_obj:Object = new Object();
                                    item_obj[columnLabel] = attrib.toString();
                                    _dataGrid.addItemAt(item_obj, i);
                                    i++;
                                }
                            }
                        }
                    }
                }

```

See the image for what I am getting… notice the blank cells that it inserts - how do I fix this???
