4 Replies Latest reply on Oct 28, 2011 2:42 PM by kevinklin

    Flex 4.5.1 - Datagrid wordwrap

    thibs73 Level 1

      Hi all,

       

      How do we set the wordwrap on a spark datagrid?

       

      I've tried what they mention in the docs, but doesn't work. What am I doing wrong?

       

      Thanks in advance.

       

       

       

      <s:DataGrid
                id="grid"
                width="200"
                height="300"
                horizontalScrollPolicy="off"
                variableRowHeight="true"
                >
        
                <s:dataProvider>
                          <s:ArrayList>
                                    <fx:Object
                                              name="ggggggggggggggggggggggggggggggggggggggg g g g g g g qerhqwkjerhqbwerjhqbwekrjhb  kjhbqwekjhrbqweh rk jhqbwekrjhbqwerjkhbqwkjerhbqwkjrehb qwkejhrbqwjehrbqkjwhebrkqjhwebrkqjw herb "
                                              />
                          </s:ArrayList>
                </s:dataProvider>
        
                <s:columns>
                          <s:ArrayList>
                                    <s:GridColumn
                                              dataField="name"
                                              headerText="Name"
                                              >
        
                                              <s:itemRenderer>
                                                        <fx:Component>
                                                                  <s:GridItemRenderer
                                                                            >
                                                                            <s:Label
                                                                                      id="labelDisplay"
                                                                                      left="5" top="9" right="5" bottom="5"
                                                                                      maxDisplayedLines="0"
                                                                                      />
                                                                  </s:GridItemRenderer>
                                                        </fx:Component>
                                              </s:itemRenderer>
        
                                    </s:GridColumn>
                          </s:ArrayList>
                </s:columns>
        
      </s:DataGrid>
      
      
        • 1. Re: Flex 4.5.1 - Datagrid wordwrap
          highlightscript Level 1

          try this

           

          <mx:DataGrid id="grid"

                           width="200"

                           height="300"

                           horizontalScrollPolicy="off"

                           variableRowHeight="true">

                  <mx:dataProvider>

                      <s:ArrayList>

          <fx:Object name="ggggggggggggggggggggggggggggggggggggggg g g g g g g qerhqwkjerhqbwerjhqbwekrjhb  kjhbqwekjhrbqweh rk jhqbwekrjhbqwerjkhbqwkjerhbqwkjrehb qwkejhrbqwjehrbqkjwhebrkqjhwebrkqjw herb "/>

                      </s:ArrayList>

                  </mx:dataProvider>

                  <mx:columns>

                      <mx:DataGridColumn  dataField="Id">

                          <mx:itemRenderer>

                              <fx:Component>

                                  <mx:Label

                                    text="{data.name}"/>

                              </fx:Component>

                          </mx:itemRenderer>

                      </mx:DataGridColumn>

                  </mx:columns>

              </mx:DataGrid>

          1 person found this helpful
          • 2. Re: Flex 4.5.1 - Datagrid wordwrap
            kevinklin Adobe Employee

            Hi thibs,

             

            There's a whole blog post that Hans (one of our engineers) wrote on this subject here: http://hansmuller-flex.blogspot.com/2011/05/controlling-text-wrapping-in-datagrid.html.

             

            A quick and dirty work around is to set a width on your GridColumn.

             

            -Kevin

            1 person found this helpful
            • 3. Re: Flex 4.5.1 - Datagrid wordwrap
              thibs73 Level 1

              Thank-you for you're help. I did read that post, for some reason it wasn't working for me. I had to add a typicalItem with the variableRowHeight, the variableRowHeight alone didn't work.

               

              cheers

              • 4. Re: Flex 4.5.1 - Datagrid wordwrap
                kevinklin Adobe Employee

                Yeah, I poked through the code and the typicalItem affects whether the DataGrid thinks that particular column will wrap. When it's not defined, the typicalItem is just the first item in your dataProvider. In this case, it's the really long string and so the DataGrid thinks that every item will look like that.