1. #1
    Sencha User
    Join Date
    Mar 2012
    Location
    Bangalore, India
    Posts
    139
    Vote Rating
    1
    shaleen is on a distinguished road

      0  

    Default String to int

    String to int


    hi everyone

    I am extracting values from the json files using store and model in sencha.
    some of the values extracted are int. I want to perform operation on it(mathematical)......but it is a string.

    How can i convert this string to int or is there any other way of doing mathematical operation on them.

    This is coming from json file-
    open_value=this.get('open');

    This is the operation which i want to do
    alert(open_value+12);

    Suppose value of open_value = 30
    then output should come 42 and not 3012 which is coming in present case

  2. #2
    Ext JS Premium Member
    Join Date
    Apr 2008
    Posts
    358
    Vote Rating
    15
    rich02818 is on a distinguished road

      0  

    Default


    Your variable open_value is being interpreted as a string, and then the + 12 is treated as string concatenation. Try this:

    alert(parseInt(open_value,10) + 12);

  3. #3
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,499
    Vote Rating
    47
    Animal has a spectacular aura about Animal has a spectacular aura about

      0  

    Default


    ExtJS does this for you.

    Just specify a field type when you define your Model.

  4. #4
    Sencha User
    Join Date
    Mar 2012
    Location
    Bangalore, India
    Posts
    139
    Vote Rating
    1
    shaleen is on a distinguished road

      0  

    Default


    Thanks its working fine.

Thread Participants: 2

Tags for this Thread

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi