-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
jsreport-core and using recipe html-with-browser-client #47
Comments
can you please share the rest of code that you are using for the rendering? i mean, i want to see how you call render and how you pass the template content (and what is the content also). if your project is tiny, then you can also upload your code to github repository and share it here, then i will take a look and check the error you are getting. |
var jsreport = require('jsreport-core')(); onJSReportStarted = () => { |
i see that the as a workaround (until we fix the usage for render with code), i think you can do this to make your render work. jsreport.render({
template: {
content: template,
engine: 'handlebars',
recipe: 'html-with-browser-client'
},
context: {
http: {
baseUrl: 'http://localhost:2000' // or put here the host and port that you are using
}
}
}) |
Amazing. With the changes that you have given my code works. Please refer to this example that I have created in JSreport online studio: I want to use the same templates in my meteor - react js app where I use JS Report-Core and render the JS report from code and not via a http call to the JS Report engine. How do I do it? These templates work in the studio. |
Ok so this is how the JSreport is getting rendered in my app: div dangerouslySetInnerHTML={{ __html: this.props.reportHTML }} That is, in the react component. This is way the script calls get disabled. Now another issue is coming up. How do I refer to the inner template in the jsreport.render method :
In Studio, its easily possible to refer to another template using the name or shortid. |
i was thinking the same, your original issue was just caused because the way React handles html
it is not possible if you don't save the template, you are rendering with anonymous templates (passing the whole template content in .render), if you need references to another template you can just save it, you can do that somewhere after your jsreport.init but before the render. // save your templates with name
jsreport.documentStore.collection('templates').insert({
name: 'listWithFilterMasterTemplate',
content: '...',
engine: 'handlebars',
recipe: 'html-with-browser-client'
}) // -> this returns promise
jsreport.documentStore.collection('templates').insert({
name: 'listWithFilterChildTemplate',
content: '...',
engine: 'handlebars',
recipe: 'html'
}) // -> this returns promise
// then in your render you can use reference by name |
We tried this solution but are still facing an issue. When rendering the report on UI, "jsreport is undefined" error is being thrown. |
@mayuradesh confirmed that it works, if it does not maybe you are using other port than 2000 and you need to adapt the code. i guess both are using the same codebase so i'm not sure why it would work for @mayuradesh but not for you. maybe it is a good idea to check deeper with @mayuradesh |
Hi,
I am using jsreport-core package in my meteor app to generate reports.
Normally I use the "html" as "recipe" and it suffices.
Now I want to include filter option in my report.
Accordingly I want to use "recipe" as "html-with-browser-client".
For doing so I have added "jsreport-browser-client" package.
But I am getting error as :
**
TypeError: Cannot read property 'baseUrl' of undefined
at Object.recipe ..\node_modules\jsreport-browser-client\lib\browser.js
at invokeRender ..\jsreport-core\lib\render\render.js
**
I made a new post on jsreport forum and got to know that I need to additionally use "jsreport-express".
https://forum.jsreport.net/topic/1105/can-i-use-html-with-browser-client-recipe-with-jsreport-core-package/3
var jsreport = require('jsreport-core')();
jsreport.use(require('jsreport-templates')());
jsreport.use(require('jsreport-handlebars')());
jsreport.use(require('jsreport-browser-client')());
jsreport.use(require('jsreport-express')({ httpPort: 2000}));
I tried still getting same error.
The text was updated successfully, but these errors were encountered: