Issue in passing json object to jsreport template
-
Hi sir,
I have a json object that is used to get data for jsreport from rest api.
Json object will be look like this,
{
"Where": {
"OperationList": [{
"EqualOperation": {
"Name": "WHReceiptGuid",
"Type": "Guid",
"Value": whReceiptGuid
},
"IterationCount": 1
}]
}
}Also iam passing above object from angular to jsreport using jsreport browser client.Here
property iterationCount value is number.But when i try to console the report data from jsreport before render function the iteration value will be converted to string ie ,{
"Where": {
"OperationList": [{
"EqualOperation": {
"Name": "WHReceiptGuid",
"Type": "Guid",
"Value": whReceiptGuid
},
"IterationCount": "1"
}]
}
}Could you please tell me why the object completely converted to string? Also how can i solve the above issue?
-
hi!
that sounds weird, because if everything is being passed as json then it should preserve the types, i don't have a good explanation at the top of my head, it will be better if you can share the template so we can analyze the execution and find the place where the number is changed to string. you can share your template in the https://playground.jsreport.net/, or add an export zip here in the comments, or send that zip privately to me at bjrmatos@gmail.com
also, please describe what jsreport version are you using.
-
Hi sir ,
I have create one sample project
Link - https://playground.jsreport.net/w/reshmajacob93/ezMJISU1Input object iam passing from angular project is,
let testObj = { x: 5, y: 6 };
var reportdata = {
template: {
recipe: 'html,
shortid: 'ezMJISU1', //Short id of the template
},
data: {
jsonObj:testObj
},
};jsreport.render('_blank', reportdata);
Result from jsreport console is,
Here value x,y is converted to string (earlier it was number).
Can you please help me how to resolve it?
-
The client
render
function in v2 doesn't propagate types.
You need to use therenderAsync
in v2, orrender
in v3.See the documentation for v2 here
https://jsreport.net/learn/browser-client?version=2.11.0
or v3 here
https://jsreport.net/learn/browser-client
-
hi sir ,
i have used renderAsync now json object type is not changing it open in new tab nut page is blank
Response---
Code-----------
jsreport.serverUrl = 'http://localhost:5488';Reponse from jsreport rendorAsync is,
bolded text
-
hi,
i have replaced the code with below now it is rendering,
Response,
But how to give report name for new tab insead of about:blank