Difficulties passing data to child template then retrieving it


  • administrators

    where toJSON is a helper defined like this:

    function toJSON(value) {
        return JSON.stringify(value)
    }
    

    but this will only work when we have support for passing objects to child templates



  • Sorry for the late answer, in the end I changed the template using assets instead of child_templates which even solved some other difficulties I had.
    But definitely thank you for taking some of your time and answering me!

    (by the way I cannot use my previous account and only facebook, twitter or github connections seems available now, is it normal?)



  • Yes, forum supports now only social logins. I apologize for inconvenience.



  • So has this been fixed?
    anytime I try to execute a child_template by passing it data
    {#child someSubReport @data.SessionID={{ this.SessionID }} @data.ClientID={{ this.ClientID }} @data.Query={{{ this.Query}}} }
    it either simply prints the text as seen above or crashes by not sending the right info.


  • administrators

    @Oshri-Cohen passing objects is still not supported. but according to your example i think it should be @this, also be sure that @this equal to your expected context (object), handlebars context is affected if you are inside an #each iteration. if you need more help create small example in playground and i will tell you why is not working as expected


  • administrators

    @Oshri-Cohen sorry, this should work just fine in template. forget the comment about @this 😃



  • how hard would it be to do this for the child-templates? Can i write my own extension for this?


  • administrators

    to be clear the snippet of code that you commented should work. if it is not working maybe is because some bad usage in the template or something else and i would need to see the full template to have an idea of the why is not working.

    what it is not supported is passing an object:

    {#child child_template @data.student={{@this}} }
    

    if you need that feature and want to try to add the support for it you can take a look at the source code and try to tweak it to add the support for the objects.



  • ok i understand, so simple items like a string can be passed, but referencing the entire object does not correct?


  • administrators

    ok i understand, so simple items like a string can be passed, but referencing the entire object does not correct?

    yes, exactly.


Log in to reply
 

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