3 Replies Latest reply on Mar 8, 2007 11:05 PM by <<Squall>>

    Restricting in a datagrid

    <<Squall>>
      Hello,
      I have created a datagrid and i have to restrict the input of one column to numbers only.
      Can someone please help do it please

      Thanx in advance
        • 1. Re: Restricting in a datagrid
          michael_ramirez44 Level 1
          You implement the NumericStepper for that column using an inline ItemRenderer.
          • 2. Restricting in a datagrid
            TucsonJava Level 1
            Another possibility, if you do not want to use a NumericStepper, is to implement an itemEditor and in the constructor indicate that input is restricted. For example,

            public function MyItemEditor(){
            super();
            super.restrict ="0-9";
            }
            • 3. Re: Restricting in a datagrid
              <<Squall>> Level 1
              public function processAtrData(event:DataGridEvent):void
              {


              // Check the reason for the event.
              var flag:Number=0;

              var item:Array=new Array();

              if (event.reason == DataGridEventReason.OTHER || event.reason == DataGridEventReason.CANCELLED)
              {
              // Do not update cell.
              return;
              }

              if(event.columnIndex==5)
              {
              //Alert.show(new String(event.columnIndex));
              info.getItemAt(event.rowIndex).atrpercentagelv1=TextInput(atr_dg.itemEditorInstance).text



              id_market=atr_dg.dataProvider[event.rowIndex].market_id;
              atrperclv1=atr_dg.dataProvider[event.rowIndex].atrpercentagelv1;
              atr=atr_dg.dataProvider[event.rowIndex].atr;
              ticksize=atr_dg.dataProvider[event.rowIndex].tick_size;
              ref_price=atr_dg.dataProvider[event.rowIndex].ref_price;
              buysell=atr_dg.dataProvider[event.rowIndex].buysell;
              atrpercentagelv1=atrperclv1/100;
              atrperlv1=(atr/ticksize)*atrpercentagelv1


              info.getItemAt(event.rowIndex).atrperlv1=PrepForDisplay.format(atrperlv1);

              if(buysell=="B" || buysell=="b")
              {
              tradepricelv1=ref_price-(atrperlv1*ticksize);
              }
              else if(buysell=="S" || buysell=="s")
              {
              tradepricelv1=ref_price+(atrperlv1*ticksize);
              }

              info.getItemAt(event.rowIndex).tradepricelv1=TradeDisplay.format(tradepricelv1);

              // atr_dg.dataProvider=atrchange;
              //Alert.show(new String(atrperlv1));


              atr_dg.dataProvider=info;
              //myService.getinfo(atrper);


              }

              Hello above is a piece of my code and i need to restrict to numbers only while inputing in the column 5
              can you please help me
              thnx