Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add wordWrap on spark GridColumn

Today, I decided to test spark datagrid instead of mx:Datatagrid. But a problem appear: I didn't found wordWrap option, do you know how to solve that?

<s:DataGrid id="scrollableDG" borderVisible="true"  editable="true"
                     width="100%" height="{bgSuivi.height-90-90}">

 //Setup columns for scrollable datagrid
    var gridColumn:GridColumn = new GridColumn();
    gridColumn.dataField="scRub2";
    gridColumn.headerText = "Rub1";
    gridColumn.width = 80;
    gridColumn.editable = true;
    columnLst.addItem(gridColumn);

    var gridColumn:GridColumn = new GridColumn();
    gridColumn.dataField="scRub3";
    gridColumn.headerText = "Rub1";
    gridColumn.width = 80;
    gridColumn.editable = true;
    columnLst.addItem(gridColumn);

    var gridColumn:GridColumn = new GridColumn();
    gridColumn.dataField="scRub4";
    gridColumn.headerText = "Rub1";
    gridColumn.width = 80;
    gridColumn.editable = true;
    columnLst.addItem(gridColumn);
    scrollableDG.columns = columnLst;

Thanks

like image 350
Flex60460 Avatar asked May 24 '12 16:05

Flex60460


1 Answers

The original poster didn't select an answer I'm going to combine the previous two into one super answr! :P

You can enable word wrapping on all columns on the Spark DataGrid with variableRowHeight:

<s:DataGrid variableRowHeight="true">
</s:DataGrid>

Or you can enable word wrapping on an individual column by using the word wrap property on the default GridColumn item renderer:

<s:GridColumn dataField="fields.description" headerText="Description" >
    <s:itemRenderer>
        <fx:Component>
            <s:DefaultGridItemRenderer wordWrap="true"/>
        </fx:Component>
    </s:itemRenderer>
</s:GridColumn>

Furthermore, in the Grid Column example I'd recommend setting a width if you want to prevent horizontal scroll bars:

<s:GridColumn width="{dataGrid.width-column1.width-column3.width}" dataField="fields.description" headerText="Description" >
    <s:itemRenderer>
        <fx:Component>
            <s:DefaultGridItemRenderer wordWrap="true"/>
        </fx:Component>
    </s:itemRenderer>
</s:GridColumn>

I'm finding I have to set both variable row height to true and set the column width to get the behavior I'm looking for.

like image 169
1.21 gigawatts Avatar answered Sep 22 '22 17:09

1.21 gigawatts