2 Replies Latest reply on Jan 15, 2010 8:53 AM by Gregory Lafrance

    Message when datagrid is empty

    ol1v31r4

      I need to display dataGrid headers and the "no records" message when the
      DataGrid is empty, is there any way to achieve this?

       

      Tks

      Rafael

        • 1. Re: Message when datagrid is empty
          RK... Level 3

          Hope this link would give you some idea,

           

          http://flexoop.com/2009/03/adding-colspan-to-a-datagrid/

          • 2. Re: Message when datagrid is empty
            Gregory Lafrance Level 6

            This code answers your question:

             

            <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
              <mx:Script>
                <![CDATA[
                  import mx.controls.Alert;
                  import mx.collections.ArrayCollection;
                  [Bindable] private var ac:ArrayCollection = new ArrayCollection([]);
                  private function checkDP():void {
                    if(ac.length == 0){
                      mx.controls.Alert.show("DataGrid dataProvider is empty!");
                    }
                  }
                ]]>
              </mx:Script>
              <mx:DataGrid dataProvider="{ac}" creationComplete="checkDP()">
                <mx:columns>
                  <mx:DataGridColumn dataField="test1"/>
                  <mx:DataGridColumn dataField="test2"/>
                  <mx:DataGridColumn dataField="test3"/>
                  <mx:DataGridColumn dataField="test4"/>
                  <mx:DataGridColumn dataField="test5"/>
                </mx:columns>
              </mx:DataGrid>
            </mx:Application>
            

             

            If this post answers your question or helps, please mark it as such.


            Greg Lafrance - Flex 2 and 3 ACE certified

            www.ChikaraDev.com

            Flex / AIR Development, Training, and Support Services