0 Replies Latest reply on Jul 31, 2007 12:26 AM by san00001

    problem in populating datagrid

    san00001 Level 1
      i have one datagrid.iam populating values in datagrid from msql database.iam generating an xml file through php and populating the grid in flex application.after insertion of values in the database am clicking one button at that time the grid should populate.but its not working.if i close the application and run it again there is no problem the grid is populating.its taking the previously stored values.i think refreshing is not happening here.my code is given below. pls help me
      <?xml version="1.0" encoding="utf-8"?>

      <mx:Canvas xmlns:mx=" http://www.adobe.com/2006/mxml" creationComplete="srv3.send()" xmlns:pim="pim.*" x="0" y="0" width="1250" height="682" backgroundColor="#f7edfe" backgroundAlpha="0.96" >
      <mx:HTTPService id="srv2" result="showalert()" request="false" url=" http://localhost/sandeep/saveemp.php" method="POST">
      <mx:request>
      <empid>{empid.text}</empid>
      <empname>{empname.text}</empname>
      <job>{job.text}</job>
      <empsts>{empsts.text}</empsts>
      <subdiv>{subdiv.text}</subdiv>
      <supervi>{supervi.text}</supervi>

      </mx:request>
      </mx:HTTPService>
      <mx:HTTPService id="srv3" request="false" result="gridpopulate(event)" url=" http://localhost/sandeep/gridpopulatecheck.php" method="POST"/>





      <mx:Script>
      <![CDATA[
      import mx.controls.Alert;
      import mx.rpc.events.ResultEvent;
      private function moveemp():void
      {
      if(add.label=="Add")
      {

      empMove.end();
      empMove.xFrom=1500;
      empMove.xTo=200;
      empMove.play();
      gridpan.setVisible(false);
      add.mouseEnabled=false;
      }
      }
      private function backemp():void
      {
      empMove1.end();
      empMove1.xFrom=200;
      empMove1.xTo=1500;
      empMove1.play();
      add.mouseEnabled=true;
      gridpan.setVisible(true);
      }
      private function gridpopulate(event:ResultEvent):void
      {
      dg.dataProvider=event.result.employees.empl;
      //event.result.employees.empl.refresh();
      }
      private function showalert():void
      {
      Alert.show("Saved");
      }
      private function refresh():void
      {
      dg.dataProvider;
      }

      ]]>
      </mx:Script>
      <mx:Move id="empMove" target="{emp}" />
      <mx:Move id="empMove1" duration="10" target="{emp}" />
      <mx:ApplicationControlBar x="228" y="175" width="636" fillColors="[#fbf3fe, #ff8080]" fillAlphas="[0.01, 0.17]" height="121" cornerRadius="14">
      <mx:HBox width="219" height="56" verticalAlign="middle">
      <mx:Label text="Search By" fontSize="12" color="#0000ff"/>
      <mx:ComboBox width="81" height="19"></mx:ComboBox>
      </mx:HBox>
      <mx:HBox width="167" height="52" verticalAlign="middle">
      <mx:Label text="Search For" fontSize="12" color="#0000ff"/>
      <mx:TextInput width="84" height="20"/>
      </mx:HBox>
      <mx:Image source="images/sear.png.png"/>
      <mx:Label text="Search" fontSize="12" color="#0000ff"/>
      <mx:Image source="images/clear.png.png"/>
      <mx:Label text="Clear" fontSize="12" color="#0000ff"/>
      </mx:ApplicationControlBar>
      <mx:Label x="226" y="47" text="Employee Information" fontSize="20" fontFamily="Times New Roman" color="#0000ff" fontWeight="bold"/>
      <mx:HRule x="226" y="73" width="625" height="6" strokeColor="#400040"/>
      <mx:LinkButton id="add" x="220" y="94" label="Add" click="moveemp()" color="#0000ff"/>
      <mx:LinkButton x="290" y="94" label="Delete" color="#0000ff"/>
      <mx:Label x="255" y="136" text="Search" fontFamily="Times New Roman" fontSize="17" color="#0000ff" fontWeight="bold"/>
      <mx:Image x="223" y="127" width="41" height="41" source="images/search.png.png"/>
      <mx:Panel id="gridpan" title="PIM" height="40%" width="80%" y="330" x="60"
      paddingTop="10" paddingLeft="10" paddingRight="10" backgroundColor="#fbf3fe">
      <mx:Label width="100%" color="blue"/>

      <mx:DataGrid id="dg" width="100%" height="158" y="60" >
      <mx:columns>
      <mx:DataGridColumn dataField="employeeid" headerText="Employee id" editable="true" />
      <mx:DataGridColumn dataField="employeename" headerText="Employee Name" editable="true"/>
      <mx:DataGridColumn dataField="jobtitle" headerText="Job Title"/>
      <mx:DataGridColumn dataField="empstatus" headerText="Employment Status"/>
      <mx:DataGridColumn dataField="subdivision" headerText="Sub Division"/>
      <mx:DataGridColumn dataField="supervisor" headerText="Supervisor"/>
      </mx:columns>
      </mx:DataGrid>



      </mx:Panel>
      <mx:Panel id="emp" width="697" height="257" layout="absolute" x="1500" y="320">
      <mx:HBox x="10" y="10" width="657" height="197">
      <mx:VBox height="100%" width="133" verticalGap="30">
      <mx:Label text="Employee Id" fontSize="12" color="#0000ff"/>
      <mx:Label text="Employee Name" fontSize="12" color="#0000ff"/>
      <mx:Label text="Job Title" fontSize="12" color="#0000ff"/>
      <mx:Label text="Employment Status" fontSize="12" color="#0000ff"/>
      </mx:VBox>
      <mx:VBox height="100%" width="154" verticalGap="28">
      <mx:TextInput id="empid" width="135"/>
      <mx:TextInput id="empname" width="135"/>
      <mx:TextInput id="job" width="135"/>
      <mx:TextInput id="empsts" width="136"/>
      </mx:VBox>
      <mx:VBox height="94" width="95" verticalGap="30">
      <mx:Label text="Sub Division" fontSize="12" color="#0000ff"/>
      <mx:Label text="Supervisor" fontSize="12" color="#0000ff"/>
      </mx:VBox>
      <mx:VBox height="188" width="226" verticalGap="28">
      <mx:TextInput id="subdiv" width="115"/>
      <mx:TextInput id="supervi" width="116"/>
      <mx:HBox width="217" height="67" verticalAlign="middle">
      <mx:Image source="images/save.jpg.jpg" click="srv2.send()" autoLoad="true"/>
      <mx:Image source="images/reset.jpg.gif" autoLoad="true"/>
      <mx:Image id="back" source="images/back.jpg.jpg" click=" backemp();srv3.send();refresh()" autoLoad="true"/>
      </mx:HBox>
      </mx:VBox>
      </mx:HBox>
      </mx:Panel>
      </mx:Canvas>





      ///php file
      <?
      header('content-type: text/xml');

      //connect to the database
      $mysql = mysql_connect("localhost", "root", "");

      mysql_select_db( "hrms" );
      //if the username and email address are filled out

      //return a list of all the users
      $Query = "SELECT * from employee";
      $Result = mysql_query( $Query );
      ?>
      <employees>
      <?php
      while ( $user = mysql_fetch_object( $Result ) )
      {
      ?>
      <empl>
      <employeeid> <?php echo($user->employeeid) ?> </employeeid>
      <employeename> <?php echo($user->employeename) ?> </employeename>
      <jobtitle> <?php echo($user->jobtitle) ?> </jobtitle>
      <empstatus> <?php echo($user->empstatus) ?> </empstatus>
      <subdivision> <?php echo($user->subdivision) ?> </subdivision>
      <supervisor> <?php echo($user->supervisor) ?> </supervisor>
      </empl>
      <?
      }

      mysql_close($mysql);
      ?>
      </employees>