Bring Data into HTML field in the DocType

Hi,

I need to show the data from the database table into the HTML field of the Doctype ( custom created with ‘Setup’ Document Type).

Anybody know how to display data in the HTML field,while loading the custom created doctype.?

  1. Create html template
    e.g. andesit_karang_anyar/driver_list.html at develop · gaurav-naik/andesit_karang_anyar · GitHub
  2. add it to build.json - andesit_karang_anyar/build.json at develop · gaurav-naik/andesit_karang_anyar · GitHub
  3. add app_include_js in hooks - andesit_karang_anyar/hooks.py at develop · gaurav-naik/andesit_karang_anyar · GitHub
  4. Changes in doctype’s py andesit_karang_anyar/vehicle.py at develop · gaurav-naik/andesit_karang_anyar · GitHub
  5. Changes in doctype’s js - andesit_karang_anyar/vehicle.js at develop · gaurav-naik/andesit_karang_anyar · GitHub

This shows driver’s photo under Vehicle.

13 Likes

@revant_one
Thank you for the detailed reply…
Let me try

@revant_one Thank you for putting this out here! I am trying to understand what’s going on in the python and JS portions of your app. I am trying to strip it back to something super simple and I’m getting hung up on the way your app brings in the HTML template.
Sorry for resurrecting this thread, but I think this is a really helpful technique if I could get it working.

1 Like

frappe.render_template used in javascript returns rendered html string.

It takes 2 parameters,
template name e.g driver_list
and dictionary e.g. cur_frm.doc.__onload.

template names are defined using the first three steps 1) create a John Resig template HTML, 2) add it to build.json, 3) add it to hooks so it is available for app.

reference : jquery - How to use the John Resig JavaScript Micro-Templating engine? - Stack Overflow

instead of using tmpl() use frappe.render_template()

example using render_template in desk page

template file defined here

changes in hooks

add template to build.json

Can it be done for the web forms?

If you wish to build a custom functionality into web pages refer how current pages from www directory work.

also check documentation for portal development :
http://frappe.github.io/frappe/user/en/guides/portal-development/

how does this change after the build system change in v14? the build.json is now depricated and how to get the template to the desk?