0 Replies Latest reply on May 28, 2009 9:43 PM by sathiyabala

    How to add string in editable datagrid

    sathiyabala

      Hai

       

       

       

             I have attached the mxml below.

       

         I need to add ' ' before and after the value.

       

       

         1. here i have the mxml, run the mxml , enter some vlaue in textbox and click add button, now the values will be added

       

         2. u can see the value in single quotes ie. ' '

       

         3. now u click the Value column  u can edit the value, after editing the value will not be in ' '

       

         4. here i have a problem, if the value is not in ' ' , i cant submit that query.

       

         5. how can i add ' ' after editing .

       

       

      can any one help me

       

       

      Thanks in Advance : )

       

       

       

       

      <mx:Application

       

       

      xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"

      >

       

       

      <mx:Script>

       

      <![CDATA[

       

       

       

      // ActionScript file

      import

       

       

      mx.rpc.events.FaultEvent;

      import

       

       

      mx.controls.Alert;

       

       

       

      import

      mx.managers.CursorManager;

      import

       

       

      mx.collections.ArrayCollection;

      [

       

       

      Bindable

      ]

       

       

      public var adhoc:ArrayCollection = new

      ArrayCollection();

      [

       

       

      Bindable

      ]

       

       

       

      public var serverString = ""

      ;

       

       

      private function initImage(event:MouseEvent):void

      {

       

       

      if

      (adhoc.length > 0){

       

       

      private function onChange():void

      {

       

       

      if

      (comboBox.selectedIndex == 0){

       

       

      else

      {

       

       

      private function onChange1():void

      {

       

       

      if(combo2.selectedItem == "DATEDEPLOYED" || combo2.selectedItem == "DATEUPLOADED"

      ){

      datepick.visible =

       

       

      true

      txt.visible =

       

      false

      }

       

      else

      {

      txt.visible =

       

       

      true

      datepick.visible =

       

      false

       

      private function add():void

      {

       

       

      var

      str:String = txt.text;

       

       

       

      if(str.length == 0 && txt.visible == true

      ){

      Alert.show(

       

       

      "Value Can Not Be Empty"

      );

       

       

       

      return

      ;

       

       

      if(combo2.selectedItem != "DATEDEPLOYED" || combo2.selectedItem != "DATEUPLOADED"

      ){

       

       

      if(txt.visible == true

      ){

       

       

       

      var temp:Object = new

      Object();

       

       

      "'"+txt.text+"'"

      ;

       

       

      ""

      ;

       

       

      var

      str1:String = datepick.text;

       

       

       

      if

      (comboBox.selectedIndex == 1){

       

       

       

      if(combo2.selectedItem == "DATEDEPLOYED" || combo2.selectedItem == "DATEUPLOADED"

      ){

       

       

       

      if(str1.length == 0 && datepick.visible == true

      ){

      Alert.show(

       

       

      "Date Cannot Be Empty"

      );

      }

       

       

      else

      {

       

       

       

      var temp:Object = new

      Object();

       

       

      ""

      ;

       

       

      false

      ;

      addopenbracket.enabled =

       

       

      false

      ;

      combo2.enabled =

       

       

      false

      ;

      combo1.enabled =

       

       

      false

      ;

       

       

      private function querydelete():void

      {

       

       

      if

      (AdHoc.selectedIndex > 0) {

       

       

       

      if

      (AdHoc.selectedIndex == (adhoc.length-1)){

      adhoc[AdHoc.selectedIndex-1].cond =

       

       

      ""

      ;

      addopenbracket.enabled =

       

       

      false

      ;

      addclosebracket.enabled =

       

       

      false

      ;

      addbutton.enabled =

       

       

      false

      ;

      combo2.enabled =

       

       

      false

      ;

      combo1.enabled =

       

       

      false

      ;

       

       

      // adhocdetailgridcompilance.dataProvider = null ;

       

       

      // adhocdetailgrid.dataProvider = null ;

       

      else if

      (adhoc.length == 1) {

       

       

      // adhocdetailgridcompilance.dataProvider = null ;

       

       

      // adhocdetailgrid.dataProvider = null ;

      addopenbracket.enabled =

       

      true

      ;

      addclosebracket.enabled =

       

       

      true

      ;

      addbutton.enabled =

       

       

      true

      ;

      combo2.enabled =

       

       

      true

      ;

      combo1.enabled =

       

       

      true

      ;

      }

       

       

      else

      {

      Alert.show(

       

       

      "Select The Rows To Delete"

      );

       

       

      private function andSubmit():void

      {

       

       

      for each(var obj:Object in

      adhoc){

       

       

       

      if

      (obj.fname == combo2.selectedItem && obj.opera == combo1.selectedItem){

       

       

       

      if(combo2.selectedItem != "DATEDEPLOYED" || combo2.selectedItem != "DATEUPLOADED"

      ){

       

       

       

      if(txt.visible == true

      ){

       

       

       

      trace("2 equals"

      );

       

       

       

      var temp:Object = new

      Object();

       

       

      else

      {

       

       

       

      trace(obj.fname + ":"

      + combo2.selectedItem);

       

       

       

      trace(obj.opera + ":"

      + combo1.selectedItem);

       

       

       

      trace(obj.val + ":" + "'"+txt.text+"'"

      );

       

       

      else if

      (obj.fname == addclosebracket.label){

       

       

       

      if(combo2.selectedItem != "DATEDEPLOYED" || combo2.selectedItem != "DATEUPLOADED"

      ){

       

       

       

      if(txt.visible == true

      ){

       

       

       

      trace("2 equals"

      );

       

       

       

      var temp:Object = new

      Object();

       

       

      else

      {

       

       

       

      trace(obj.fname + ":"

      + combo2.selectedItem);

       

       

       

      trace(obj.opera + ":"

      + combo1.selectedItem);

       

       

       

      trace(obj.val + ":" + "'"+txt.text+"'"

      );

       

       

      if

      (obj.fname == combo2.selectedItem && obj.opera == combo1.selectedItem){

       

       

       

      if(combo2.selectedItem == "DATEDEPLOYED" || combo2.selectedItem == "DATEUPLOADED"

      ){

       

       

       

      if(datepick.visible == true

      ){

       

       

       

      trace("2 equals"

      );

       

       

       

      var temp:Object = new

      Object();

       

       

      else

      {

       

       

       

      trace(obj.fname + ":"

      + combo2.selectedItem);

       

       

       

      trace(obj.opera + ":"

      + combo1.selectedItem);

       

       

       

      trace(obj.val + ":"

      + datepick.text);

       

       

      else if

      (obj.fname == addclosebracket.label){

       

       

       

      if(combo2.selectedItem == "DATEDEPLOYED" || combo2.selectedItem == "DATEUPLOADED"

      ){

       

       

       

      if(txt.visible == true

      ){

       

       

       

      trace("2 equals"

      );

       

       

       

      var temp:Object = new

      Object();

       

       

      else

      {

       

       

       

      trace(obj.fname + ":"

      + combo2.selectedItem);

       

       

       

      trace(obj.opera + ":"

      + combo1.selectedItem);

       

       

       

      trace(obj.val + ":"

      + datepick.text);

       

       

      true

      ;

      addopenbracket.enabled =

       

       

      true

      ;

      combo2.enabled =

       

       

      true

      ;

      combo1.enabled =

       

       

      true

      ;

       

       

      private function orSubmit():void

      {

       

       

      for each(var obj:Object in

      adhoc){

       

       

       

      if

      (obj.fname == combo2.selectedItem && obj.opera == combo1.selectedItem){

       

       

       

      if(combo2.selectedItem != "DATEDEPLOYED" || combo2.selectedItem != "DATEUPLOADED"

      ){

       

       

       

      if(txt.visible == true

      ){

       

       

       

      trace("2 equals"

      );

       

       

       

      var temp:Object = new

      Object();

       

       

      else

      {

       

       

       

      trace(obj.fname + ":"

      + combo2.selectedItem);

       

       

       

      trace(obj.opera + ":"

      + combo1.selectedItem);

       

       

       

      trace(obj.val + ":" + "'"+txt.text+"'"

      );

       

       

      else if

      (obj.fname == addclosebracket.label){

       

       

       

      if(combo2.selectedItem != "DATEDEPLOYED" || combo2.selectedItem != "DATEUPLOADED"

      ){

       

       

       

      if(txt.visible == true

      ){

       

       

       

      trace("2 equals"

      );

       

       

       

      var temp:Object = new

      Object();

       

       

      else

      {

       

       

       

      trace(obj.fname + ":"

      + combo2.selectedItem);

       

       

       

      trace(obj.opera + ":"

      + combo1.selectedItem);

       

       

       

      trace(obj.val + ":" + "'"+txt.text+"'"

      );

       

       

      if

      (obj.fname == combo2.selectedItem && obj.opera == combo1.selectedItem){

       

       

       

      if(combo2.selectedItem == "DATEDEPLOYED" || combo2.selectedItem == "DATEUPLOADED"

      ){

       

       

       

      if(datepick.visible == true

      ){

       

       

       

      trace("2 equals"

      );

       

       

       

      var temp:Object = new

      Object();

       

       

      else

      {

       

       

       

      trace(obj.fname + ":"

      + combo2.selectedItem);

       

       

       

      trace(obj.opera + ":"

      + combo1.selectedItem);

       

       

       

      trace(obj.val + ":"

      + datepick.text);

       

       

      else if

      (obj.fname == addclosebracket.label){

       

       

       

      if(combo2.selectedItem == "DATEDEPLOYED" || combo2.selectedItem == "DATEUPLOADED"

      ){

       

       

       

      if(txt.visible == true

      ){

       

       

       

      trace("2 equals"

      );

       

       

       

      var temp:Object = new

      Object();

       

       

      else

      {

       

       

       

      trace(obj.fname + ":"

      + combo2.selectedItem);

       

       

       

      trace(obj.opera + ":"

      + combo1.selectedItem);

       

       

       

      trace(obj.val + ":"

      + datepick.text);

       

       

      true

      ;

      addopenbracket.enabled =

       

       

      true

      ;

      combo2.enabled =

       

       

      true

      ;

      combo1.enabled =

       

       

      true

      ;

       

       

      public function addOpenBracket():void

      {

       

       

      var temp:Object = new

      Object();

       

       

      false

      addclosebracket.enabled =

       

      true

       

       

      if(adhoc.length > 1 && addopenbracket.enabled == false

      ){

      addbutton.enabled =

       

       

      true

       

      public function addCloseBracket():void

      {

       

       

      var temp:Object = new

      Object();

       

       

       

      if

      (adhoc.length > 1){

       

       

      true

      addclosebracket.enabled =

       

      false

       

       

      if(adhoc.length > 1 && addclosebracket.enabled == false

      ){

      addbutton.enabled =

       

       

      true

       

      private function dateChange(date:Date):void

      {

       

       

      if (date == null

      ){

       

       

      else

      {

      txt.text = date.getDate() +

       

       

      '/' + (date.getMonth()+1).toString() + '/'

      +

       

       

      public function saveadhoc(event:Event):void

      {

       

       

      var AdhocRows:String = ""

      ;

       

       

       

      var

      i:int ;

       

       

       

      var

      selectedType = comboBox.selectedItem;

       

       

      /* if(editVal.substring(0,1) != "'"){

       

       

       

       

       

      if

      (adhoc.length == 0){

      Alert.show(

       

       

      "Enter The Query"

      );

      }

       

       

      else

      {

       

       

      for

      (i = 0; i < adhoc.length;i++) {

       

       

       

      if(adhoc[i].fname != null

      ){

      AdhocRows = AdhocRows +adhoc[i].fname+

       

       

      " "

      ;

       

       

      if(adhoc[i].opera != null

      ){

      AdhocRows = AdhocRows + adhoc[i].opera+

       

       

      " "

      ;

       

       

      if(adhoc[i].val != null

      ){

      AdhocRows = AdhocRows + adhoc[i].val+

       

       

      " "

      ;

       

       

      if(adhoc[i].cond != null

      ){

      AdhocRows = AdhocRows + adhoc[i].cond+

       

       

      " "

      ;

       

       

      var parameters:Object = {adhocquery:AdhocRows,FlexActionType:"ADHOCQUERYSUBMIT"

      ,adhocType:selectedType};

       

       

       

      // adhocClick.send(parameters);

       

      private function retrieve():void

      {

       

       

      false

      txt.visible =

       

      true

      </mx:Script>

       

       

       

      <mx:Array id="comp"

      >

       

       

      <mx:String>TYPE</mx:String>

       

       

       

      <mx:String>AUDITRESULT

      </mx:String>

       

       

      <mx:String>CATEGORY

      </mx:String>

       

       

      <mx:String>CHILDRULE</mx:String>

       

       

       

      <mx:String>PARENTRULE

      </mx:String>

       

       

      <mx:String>AUDITGROUP

      </mx:String>

       

       

      <mx:String>LOCATION

      </mx:String>

       

       

      <mx:String>VENDOR

      </mx:String>

       

       

      <mx:String>DEVICECATEGORY

      </mx:String>

       

       

      </mx:Array>

       

       

       

       

      <mx:Array id="inven"

      >

       

       

      <mx:String>VENDOR

      </mx:String>

       

       

      <mx:String>DEVICETYPE

      </mx:String>

       

       

      <mx:String>SERIES

      </mx:String>

       

       

      <mx:String>MODEL

      </mx:String>

       

       

      <mx:String>SUP/CPU

      </mx:String>

       

       

      <mx:String>CODEVERSION

      </mx:String>

       

       

      <mx:String>IMAGENAME

      </mx:String>

       

       

      <mx:String>DATEDEPLOYED

      </mx:String>

       

       

      <mx:String>LOCATIONNAME

      </mx:String>

       

       

      <mx:String>ADDRESS1

      </mx:String>

       

       

      <mx:String>ADDRESS2

      </mx:String>

       

       

      <mx:String>CITY

      </mx:String>

       

       

      <mx:String>STATE

      </mx:String>

       

       

      <mx:String>COUNTRY

      </mx:String>

       

       

      <mx:String>FLOOR</mx:String>

       

       

       

      <mx:String>CABINET

      </mx:String>

       

       

      <mx:String>CATEGORYNAME

      </mx:String>

       

       

      <mx:String>DEPARTMENT

      </mx:String>

       

       

      <mx:String>CONTACTNAME

      </mx:String>

       

       

      <mx:String>CONTACTNUMBER

      </mx:String>

       

       

      <mx:String>VERSION

      </mx:String>

       

       

      <mx:String>FILENAME

      </mx:String>

       

       

      <mx:String>DATEUPLOADED

      </mx:String>

       

       

      </mx:Array>

       

       

       

      <mx:Accordion x="13" y="55" width="230" height="492"

      >

      <mx:Form

       

       

       

      label="AdHoc Query Analyzer" width="100%" creationComplete="retrieve()" height="100%" color="#F2F8F9" backgroundColor="#020202"

      >

       

       

      <mx:Canvas label="Query" width="204" height="440" backgroundColor="#020202"

      >

       

       

      <mx:ComboBox x="66" y="287" width="134" id="comboBox" dataProvider="[COMPLIANCE , INVENTORY]" change="onChange()" color="#050505">

       

       

       

      </mx:ComboBox>

       

       

      <mx:ComboBox x="5" y="344" width="109.25" id="combo1" dataProvider="[=,!=,>,>=,&lt;,&lt;=,LIKE]" color="#010101"

      ></mx:ComboBox>

       

       

      <mx:TextInput x="119.25" y="344" width="77.75" id="txt" color="#050505"

      />

       

       

      <mx:Button x="3" y="401" label="Add" width="59" click="add()" id="addbutton" color="#FFFEFE" fillAlphas="[0.6, 0.4, 0.75, 0.65]" fillColors="[#FFFFFF, #CCCCCC, #EEEEEE, #EEEEEE]" borderColor="#B7BABC" themeColor="#009DFF"

      />

       

       

      <mx:Button x="66" y="401" label="Delete" width="63.25" click="querydelete()" color="#FFFEFE" fillAlphas="[0.6, 0.4, 0.75, 0.65]" fillColors="[#FFFFFF, #CCCCCC, #EEEEEE, #EEEEEE]" borderColor="#B7BABC" themeColor="#009DFF"

      />

       

       

      <mx:Button x="2" y="373" label="(" id="addopenbracket" click="addOpenBracket()" width="45" color="#FFFEFE" fillAlphas="[0.6, 0.4, 0.75, 0.65]" fillColors="[#FFFFFF, #CCCCCC, #EEEEEE, #EEEEEE]" borderColor="#B7BABC" themeColor="#009DFF"

      />

       

       

      <mx:Button x="51" y="373" label=")" id="addclosebracket" click="addCloseBracket()" width="45" color="#FFFEFE" fillAlphas="[0.6, 0.4, 0.75, 0.65]" fillColors="[#FFFFFF, #CCCCCC, #EEEEEE, #EEEEEE]" borderColor="#B7BABC" themeColor="#009DFF"

      />

       

       

      <mx:Button x="134.25" y="401" label="Submit" click="saveadhoc(event);initImage(event)" color="#FFFEFE" fillAlphas="[1.0, 0.69, 0.75, 0.65]" fillColors="[#77B97A, #77B97A, #EEEEEE, #EEEEEE]" borderColor="#77B97A" themeColor="#009DFF"

      />

       

       

       

      <mx:ComboBox x="66" y="317" width="134" id="combo2" change="onChange1()" dataProvider="{comp}" color="#010101"

      >

       

       

      </mx:ComboBox>

       

       

      <mx:DateField x="122.25" y="344" width="74.75" initialize="dateChange((event.target).selectedDate)" id="datepick" color="#050505"

      />

       

       

      <mx:DataGrid x="1" y="1" width="203" height="282" id="AdHoc" dataProvider="{adhoc}" allowMultipleSelection="true" color="#020202"

      >

       

       

      <mx:columns>

       

       

      <mx:DataGridColumn headerText="Name" dataField="fname" id="fnam"

      />

       

       

      <mx:DataGridColumn headerText="Operator" dataField="opera" id="ope"

      />

       

       

      <mx:DataGridColumn headerText="Value" dataField="val" id="valu"

      />

       

       

      <mx:DataGridColumn headerText="Condition" dataField="cond" id="condt"

      />

       

       

      </mx:columns>

       

       

      </mx:DataGrid>

       

       

      <mx:Button x="99" y="373" label="AND" width="52" click="andSubmit()" id="and" color="#FFFEFE" fillAlphas="[0.6, 0.4, 0.75, 0.65]" fillColors="[#FFFFFF, #CCCCCC, #EEEEEE, #EEEEEE]" borderColor="#B7BABC" themeColor="#009DFF"

      />

       

       

      <mx:Button x="154" y="373" label="OR" width="49" click="orSubmit()" id="or" color="#FFFEFE" fillAlphas="[0.6, 0.4, 0.75, 0.65]" fillColors="[#FFFFFF, #CCCCCC, #EEEEEE, #EEEEEE]" borderColor="#B7BABC" themeColor="#009DFF"

      />

       

       

      <mx:Label x="7" y="291" text="TYPE" width="59" fontWeight="bold"

      />

       

       

      <mx:Label x="5" y="319" text="DISPLAY" width="59" fontWeight="bold"

      />

       

       

      </mx:Canvas>

       

       

      </mx:Form>

       

       

      </mx:Accordion>

       

      </mx:Application>

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

      }

       

       

       

       

      ]]>

       

      datepick.visible =

      }

      }

       

       

      }

       

      }

       

      }

       

      }

       

      }

       

       

       

       

       

      Alert.show("Inside IF111::::;"+AdhocRows);

      AdhocRows = "'"+adhoc[i].val+"'";

      //AdhocRows = AdhocRows + adhoc[i].val+" ";

      }

      if(editVal.substring(editVal.length-1,editVal.length) != "'"){

      Alert.show("Inside IF 222::::;"+AdhocRows);

      AdhocRows = adhoc[i].val+"'";

      }*/

       

       

       

       

      date.getFullYear().toString() ;

      }

       

      }

       

       

      }

       

       

      }

      }

       

      }

       

      temp.fname = addclosebracket.label

      adhoc.addItem(temp);

      addopenbracket.enabled =

       

       

      }

       

      }

       

       

      temp.fname = addopenbracket.label

      adhoc.addItem(temp);

      addopenbracket.enabled =

       

       

      }

       

       

      }

      }

      }

      }

      addbutton.enabled =

      obj.cond = or.label

      adhoc.setItemAt(obj,adhoc.getItemIndex(obj));

      }

      }

      }

      }

      obj.cond = or.label

      adhoc.setItemAt(obj,adhoc.getItemIndex(obj));

      }

      }

      }

      }

       

       

      obj.cond = or.label

      adhoc.setItemAt(obj,adhoc.getItemIndex(obj));

      }

      }

      }

      }

      obj.cond = or.label

      adhoc.setItemAt(obj,adhoc.getItemIndex(obj));

      }

       

       

      }

       

       

      }

      }

      }

      }

      addbutton.enabled =

      obj.cond = and.label

      adhoc.setItemAt(obj,adhoc.getItemIndex(obj));

      }

      }

      }

      }

      obj.cond = and.label

      adhoc.setItemAt(obj,adhoc.getItemIndex(obj));

      }

      }

      }

      }

       

       

      obj.cond = and.label

      adhoc.setItemAt(obj,adhoc.getItemIndex(obj));

      }

      }

      }

      }

      obj.cond = and.label

      adhoc.setItemAt(obj,adhoc.getItemIndex(obj));

      }

       

       

      }

       

       

       

      }

       

       

      adhoc.removeItemAt(AdHoc.selectedIndex);

       

       

      }

      }

      combo2.selectedItem = adhoc[adhoc.length-2].fname

      combo1.selectedItem = adhoc[adhoc.length-2].opera

      adhoc.removeItemAt(AdHoc.selectedIndex);

       

       

       

      }

       

       

      }

      }

      }

       

      addbutton.enabled =

      temp.fname = combo2.selectedItem;

      temp.opera = combo1.selectedItem;

      temp.val = datepick.text;

      adhoc.addItem(temp);

      datepick.text =

      }

      }

       

       

      adhoc.addItem(temp);

      txt.text =

      temp.fname = combo2.selectedItem;

      temp.opera = combo1.selectedItem;

      temp.val =

       

       

      }

       

       

       

       

      }

       

      }

       

       

       

       

       

      }

      }

       

       

       

       

      }

       

       

      CursorManager.setBusyCursor();

      }

       

      }

       

       

       

       

       

       

       

       

       

       

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