0 Replies Latest reply on Nov 5, 2006 7:33 PM by luciewong

    add record to the end of DataSet collection

    luciewong Level 1
      Hi,
      hope someone can help me, please.

      The code below does the following.
      It searches the DataSet if the records exist, if YES it changes a particalur value, if NOT it adds a new record to the DataSet.
      The Problem:
      If the record is new added, it is added always somewhere in the middle of the collection, never at the end.
      I want it added as the last record, so it is easy to control in the binded DataGrid.
      Otherwise, if you have a large number of records, you never find the new added record in the DataGrid.

      So..., I have tried many things, it only adds the record to the end, when I remove before the SORT id, I have defined, but I cant do that.
      >myDSA3.last(); < just does not work. Do I something wrong?



      function storeSelFormatBold(){
      //xxxxxxxxxxxxxxxxx
      recID++;
      var s:String; s = _root.singleCount.text;
      selId = (s+TFtoChange+TFbeginS+_level0.BoxDW);
      selBox = BoxDW;
      selTextField = catchTF+i;
      selPage = _root.singleCount.text;
      selText = changeText.text;
      selStart = TFbeginS;
      // if selStart is -1< then we have a selection error/show warning
      var testval = selStart;
      if(testval == null){
      //xxxxxxxxxxxxxxxxx
      playMouseError();//shows WARNING
      }else{
      if(myDSA3.find([selBox,selTextField,selPage,selText,selStart])) {
      var itemNo:String = myDSA3.getItemId();
      }
      //xxx
      if(itemNo != null) {
      //xxxxxxxxxxxxxxxxxx
      myDSA3.locateById(itemNo);
      recordID = itemNo;
      myDSA3.selBold = showAlertFormat.bold;
      myDSA3.addItem(selBold);
      //xxx
      }else{
      //myDSA3.removeSort("record");//<<now I could move to Last, but I cant remove the Sort
      //5/11/06>below does not work alone as long there is a Sort<<
      myDSA3.last();//new5/11/06<</rec is always somewhere else/I want it added at end

      var newRec = new Array();
      newRec= [{recID:Number,selId:String,selBox:String,selTextField:String,selPage:String,selText:Stri ng, selStart:Number,selEnd:Number,selBold:Boolean}];
      //xxx
      newRec.recID = recID;
      newRec.selId = (s+TFtoChange+TFbeginS+_level0.BoxDW);
      newRec.selBox = BoxDW;
      newRec.selTextField = catchTF+i;
      newRec.selPage = _root.singleCount.text;
      newRec.selText = changeText.text;
      newRec.selStart = TFbeginS;//
      newRec.selEnd = TFendS;//
      newRec.selBold = showAlertFormat.bold;
      //xxxxx
      myDSA3.addItem(newRec);

      };
      //xxxxxendof storeSelFormatBoldxxxxx

      Best regards,
      Luciewong