Web forum is in read-only mode. Login as active registered customer for write access
  Forum Search   New Posts New Posts

Handle JS object key's value is false for field ?

 Post Reply Post Reply
Author
Chia Kalmen View Drop Down
Senior Member
Senior Member
Avatar

Joined: 26 Jan 2019
Posts: 120
Post Options Post Options   Quote Chia Kalmen Quote  Post ReplyReply Direct Link To This Post Topic: Handle JS object key's value is false for field ?
    Posted: 17 May 2019 at 8:37am
Hi , as i am loading and parsing the JSON string into data for TWebClientDataset.row , sometimes in my chrome dev Tool console , i noticed some error caused by 

Data = "[  { "id":1 , "name": "something" , "company_add1": false } ,
    { "id":1 , "name": "something" , "company_add1": "some streets" , "tel":"+6012345678"  }
]";

The Data will need to parse into TJSArray(TJSJSON.parseObject(_data)) before it can be loaded ,

when i try to convert it into the FIRST TWebClientDataset , 
i think it accept all values and open the dataset automatically without issue , but when i try to copy the Data/Records to ANOTHER TWebClientDataset, 

i saw some error like ...  AValue = False , not known type (something like this) ,

my questions are as follow ,
1. i am thinking to parse the above data in my ASM Block and considering remove all the value
   which has false as it's value using JS function
   before loading it to "ROW" property of dataset , is that the right way to do so ?

2. from the above data , i purposely put the second set / row in the array , where it has additional 
    "tel" , key / field , if i DO NOT use the TField editor to create the related fields,and allowing TMS 
    Webcore to auto create the field when it loads the ROW from a parseObject  , ie id, name , 
   address_add1 , tel ,

   SO... will the JSON object when get loaded into the TDataset will AUTO create the
   field , especially the "tel" field correctly because the field only appear at the second row ?

please help to clarify , thanks.
  
Back to Top
Chia Kalmen View Drop Down
Senior Member
Senior Member
Avatar

Joined: 26 Jan 2019
Posts: 120
Post Options Post Options   Quote Chia Kalmen Quote  Post ReplyReply Direct Link To This Post Posted: 17 May 2019 at 9:13am
HI , just hope the image in this URL can help for you to advice , what is the best way to handle https://snag.gy/yrUgjz.jpg , when the AValue = false .

as the field company_id original is a string type, but as my server will return false as a null or blank string value  (python default behavior) , what is the best way to handle this ?

perhaps a recommendation of the proper JSON code for the TMS Webcore TDataset to correctly handle the TField type will be helpful , please advice .

Do appreciate if you can look into 2 of my questions above, thanks.
https://snag.gy/yrUgjz.jpg
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down