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?


  • administrators

    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/ezMJISU1

    Input 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,

    0_1637427709223_upload-abf0beca-c622-44da-b3bb-660ab12b5fef

    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 the renderAsync in v2, or render 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---
    0_1637430469070_upload-58aa6277-7dc1-4ae1-bf55-96d354d5d3bf

    Code-----------
    jsreport.serverUrl = 'http://localhost:5488';

    0_1637429681161_upload-6e5ae3d1-dbe8-43e5-afca-b0c20e9d3600

    Reponse from jsreport rendorAsync is,

    0_1637430006779_upload-3d5648d3-0b1c-4ed0-83ce-e56b18bdfc3f

    bolded text



  • hi,

    i have replaced the code with below now it is rendering,

    0_1637431942605_upload-370e6604-ce6c-427b-80dc-a68e6780b53b

    Response,

    0_1637432154659_upload-5065a58b-70d8-4da8-8f14-fcadb27f8dba

    But how to give report name for new tab insead of about:blank


Log in to reply
 

Looks like your connection to jsreport forum was lost, please wait while we try to reconnect.