开发者

Facing extra row in the data grid?

I am generating A datagrid with Array collection. When The datagrid is generated some extra row are created at the end of grid. How i remove that extra Row or stop them to generate.

My code that generate Grid

private function createGrid(dataPrvdr:ArrayCollection, columnsValue:Array /*of Objects*/ = null):void
        {
            if (dataPrvdr && dataPrvdr.length)
            {
                includeInLayout = true;
                var grid:DataGrid = new DataGrid();

                开发者_JAVA技巧if (columnsValue)
                {
                    var cols:Array = grid.columns;
                    for (var i:int = 0; i < columnsValue.length; i++)
                    {
                        for (var prop:String in columnsValue[i])
                        {
                            //addDataGridColumn(prop, columnsValue[i][prop], grid);
                            cols.push(DataGridColumn(columnsValue[i][prop]));
                        }
                    }

                    grid.columns = cols;
                }

                grid.dataProvider = dataPrvdr;
                grid.percentWidth = 99;
                grid.styleName = "dataGridReport";  
                grid.setStyle("headerBackgroundSkin",DataGridHeaderBlueSkin); 

                grid.sortableColumns = false;
                grid.editable = false;
                grid.variableRowHeight = true;
                grid.resizableColumns = false;

                grid.rowCount = grid.dataProvider.length;
                grid.headerHeight = 20;
                grid.rowHeight = 16;
                grid.verticalScrollPolicy = ScrollPolicy.OFF;
                addElement(grid);

                if (!grids)
                    grids = [];

                grids.push(grid);
                grid.addEventListener("multiLineLabelItemRendererHeightChanged", rendererHeightChanged, false, 0, true);
                grid.addEventListener(FlexEvent.CREATION_COMPLETE, function (event:FlexEvent):void
                {
                    grid.invalidateSize();
                }, false, 0, true);
            }
        }

Thanks


When you set the height property of the datagrid, it overrides the rowCount

You can set the height in your code as:

grid.height = grid.dataProvider.length * grid.rowHeight + grid.headerHeight;

Cheers,

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜