2 Replies Latest reply on Aug 12, 2009 8:15 AM by quebequiano

    Resize a datagrid dinamically

    quebequiano Level 1

      Hello, I have a DataGrid and i populate it dinamically with a button. The problem is I don't know how to resize de DataGrid to have all the information without scroll bars.

        • 1. Re: Resize a datagrid dinamically
          Kenny Yates Level 2

          We need more information.

          There are simply too many variables involved to answer this with limited knowledge.

          Perhaps you can show us the MXML code for your grid and layout that would help.


          You should be setting your Data Grid using absolute sizes (100%, etc) and not using Pixel widths and heights unless necessary as this keeps the DG from resizing as resolutions change.

           

          To set a DG programmatically you would use

          myDataGrid.percentHeight = 100; (that would be 100%)

          myDataGrid.percentWidth = 100;

           

          As I said, give us some code to look at and we should be able to assist you.

           

          HTH,

          Kenny Yates

          • 2. Re: Resize a datagrid dinamically
            quebequiano Level 1

            DATA GRID

             

             

            <mx:DataGrid width="478"
                             id="listApplications"
                             editable="false"
                             styleName="dataGrid" height="212">
                    <mx:columns>

             

                        <mx:DataGridColumn headerText="ID"
                                           dataField="col1">

             

                            <mx:itemRenderer>
                                <mx:Component>
                                    <mx:Label text="{data.idApplication}"/>
                                </mx:Component>
                            </mx:itemRenderer>

             

                        </mx:DataGridColumn>

             


                        <mx:DataGridColumn headerText="Application"
                                           dataField="col2">
                            <mx:itemRenderer>
                                <mx:Component>
                                    <mx:Label text="{data.nameApplication}"/>
                                </mx:Component>
                            </mx:itemRenderer>

             

                </mx:DataGridColumn>

             

                    </mx:columns>

             

             

             


                </mx:DataGrid>



            ACTION SCRIPT (Using a Java Remote Service)

             

             

                        public function getData():void
                        {
                            staticDataOpRO.getListOfApplications.addEventListener(ResultEvent.RESULT, getListOfApplicationsHandler, false, 0, true);
                            staticDataOpRO.getListOfApplications();

             

                        }

             

                        public function getListOfApplicationsHandler(event:ResultEvent):void
                        {

             

                            var list:ArrayCollection=ArrayCollection(event.result);
                            listApplications.dataProvider=list;

             


                        }