Two digit number not displaying on label

nativescriptcore

#1

I am having strange problem with my UI. I have barcode scanner in my phone so I am scanning barcode and storing it to observable array (That’s working fine). I also have one label where I am displaying length of array.
everytime I add new item the label text is changing as per length of array but once the length increase to 10 it’s stop displaying in UI.

XML

          <Label length="4" text="{{ qty }}" />

Javascript

          var qty = dockReceive.wayBills.length
          dockReceive.set("qty",qty);

model class dockReceive

    var observableModule = require("data/observable");
    var observableArrayModule = require("data/observable-array");

 function DockReceive(info) {
 info = info || {};
console.log("in dock receive");

   var viewModel = new observableModule.fromObject({

  wayBills: info.wayBills || new observableArrayModule.ObservableArray(),
   qty: info.qty || 00,
}); 
 return viewModel;
}
 module.exports = DockReceive;

Please help me to find out solution for this strange problem.


#2

Try using dockReceive.set("qty", qty.toString()); instead.


#3

no that’s not working


#4

Is it issue Android / iOS? Can you try reproducing the issue with Playground?


#5

This issue is on android device.
how can I implement barcode scanner thing in playground?


#6

Do you see any errors in console already? Also give this a try

var isAndroid = require("platform").isAndroid;
dockReceive.set("qty", isAndroid ? java.lang.String.valueOf(qty) : qty);

#7

in console I can see changes of qty though it went pass 9 but I am not able to see on UI. If I navigate back to previous page and Come back to same page Then number start displaying.

I have tried your code but same problem.


#8

I assumed it may be type casting problem, looks like not. You may try sharing a clean sample project where we can see the issue.


#9

one more thing I have two mechanism to add data in list view

  1. Using Barcode Scanner (Broadcast receiver through) - problem
  2. enter manually and click on add this is working perfectly fine.

#10

Could you make a reproducible sample and upload it on github? Perhaps the 2 digit number is treated like a character code, and that’s the reason it isn’t being displayed


#11

I tried this

    dockReceive.set("qty",dockReceive.get("qty")+1);

it’s still not displaying number so I try to reproduce it in playground and it worked perfectly there here is the link - https://play.nativescript.org/?template=play-js&id=9IbIk4


#12

I thought so, which is why I expected java.lang.String.valueOf to solve this problem, but it didn’t do it seems :disappointed_relieved:

@radhe12 Try sharing a clean sample through Github.


#13

Strange but this is my solution. I added width property of label

           <StackLayout orientation="horizontal" row="3" column="0" id="wbcount" visibility="hidden">
           <Label text="Received Waybill(s) :  " width="55%" /><Label text="{{rwbqty}}" width="40%" />
           </StackLayout>