4 Replies Latest reply on Mar 17, 2010 9:46 AM by Flex harUI

    Problem with empty DataGrid


      I have a DataGrid that return a dataProvider (consulting with php language).
      I would like to show a menssage like "No data returned" or "Datagrid is empty" when this consulting dont return anything and the DataGrid be empty
      How i can do it?
      Thanks since now

        • 1. Re: Problem with empty DataGrid
          Matt Le Fevre Level 4

          i imagine you already have something like


          datagrid.dataProvider = event.result.whatever;



          you could always do something like

          datagrid.dataProvider = event.result.whatever;
          Alert.show(Datagrid is empty!);




          if(event.result != null)
          datagrid.dataProvider = event.result.whatever;
          Alert.show(Datagrid is empty!);


          depends on how your code is set out, if you have a sample post it up

          1 person found this helpful
          • 2. Re: Problem with empty DataGrid
            Jotajota-br Level 1


            I imagined I need to do something in the MXML to show to mensagem into DataGrid without the columns.

            I'm  sorry if I'm very confused

            But I'll try it. thanks


            Message was edited by: Paulo Roberto de Camargo Mello Junior

            • 3. Re: Problem with empty DataGrid
              Jotajota-br Level 1

              This is my code and the explain what I would like to do.


              <?xml version="1.0" encoding="utf-8"?>


              <mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="funcService.send()" >








                          import mx.controls.Alert;


                          import mx.collections.XMLListCollection;


                          import mx.rpc.events.ResultEvent;






                          private var funcData:XMLListCollection = new XMLListCollection;




                          private function niverHandler(event:ResultEvent):void{


                              var funcResultData:XMLList = new XMLList();


                              funcResultData = event.result.partiner;


                              funcData.source = funcResultData;


                              if (event.result == null){


                                  Alert.show("DataGrid is empty!");












                  <mx:HTTPService id="funcService" url="xml/xml_birthdayDayLdap.php"


                      result="niverHandler(event)" resultFormat="e4x" />



                  <mx:DataGrid id="dgUserRequest" dataProvider="{funcData}" horizontalCenter="0"        rowCount="5" alternatingItemColors="[#CCCCCC,#AAAAAA]" >

              Here i would like  analyze if the dataProvider is empty
                  if dataProvider is empty  I would like to show a mensage "DataGrid is empty" without columns
                  if not I would like to show de columns normally

                          <mx:DataGridColumn headerText="Place" dataField="place" width="50" textAlign="center" />
                          <mx:DataGridColumn headerText="Name" dataField="name_partner" width="130" />

              I yet don't know how to do it.

              Thanks again.

              • 4. Re: Problem with empty DataGrid
                Flex harUI Adobe Employee

                Just place a Label of the DataGrid with

                visible="{dgUserRequest.dataProvider.length == 0}"