We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Column Template with Jinja2?

In your examples regarding column templates you use {{  }} to delineate placeholders for the template.  Unfortunately for me, the template engine I am using for my site, Jinja2, also uses those symbols.  Jinja2 is going to intercept the template and throw an error.  Is there any way to re-define the symbols that are used in the template engine for the column template?  Is there a way I could use, say {!  !}? Or some other combination is fine, so long as it doesn't collide with Jinja2.

4 Replies

BV Bruce Van Horn replied to Bruce Van Horn October 28, 2015 07:37 PM UTC

In your examples regarding column templates you use {{  }} to delineate placeholders for the template.  Unfortunately for me, the template engine I am using for my site, Jinja2, also uses those symbols.  Jinja2 is going to intercept the template and throw an error.  Is there any way to re-define the symbols that are used in the template engine for the column template?  Is there a way I could use, say {!  !}? Or some other combination is fine, so long as it doesn't collide with Jinja2.

Never mind - I figured out how to work around it using queryCellInfo and changing the inner html rather than using a column template.

$("#grid").ejGrid({
dataSource: data['health_details'],
allowPaging: true,
allowGrouping: true,
groupSettings: {groupedColumns: ["category", "alert_level"]},
columns: [
{field: "category", headerText: "Category", width: 200},
{field: "alert_level", headerText: "Alert Level", width: 130},
{field: "description", headerText: "Description"}

],
queryCellInfo: function (args) {
var value = args.text.replace(",", "");
switch (args.column.headerText) {
case "Category":
switch (parseFloat(value)) {
case 0:
args.cell.innerHTML = '<img src="../static/img/Health-0.png"/>';
break;
case 1:
args.cell.innerHTML = '<img src="../static/img/Health-1.png"/>';
break;
case 2:
args.cell.innerHTML = '<img src="../static/img/Health-2.png"/>';
break;
case 3:
args.cell.innerHTML = '<img src="../static/img/Health-3.png"/>';
break;
default:
args.cell.innerHTML = '<img src="../static/img/Health-4.png"/>';
break;
}
}
}
});


BV Bruce Van Horn October 28, 2015 07:39 PM UTC

Dude, that was awesome!  Somebody ought to give you a job doing this.


BV Bruce Van Horn October 28, 2015 07:40 PM UTC

Thank you.


SR Sellappandi Ramu Syncfusion Team October 29, 2015 04:39 AM UTC

Hi Bruce Van Horn,

Thanks for the update.

Please get back to us if you have any queries. We are happy to assist you.

Regards,
Sellappandi R

Loader.
Live Chat Icon For mobile
Up arrow icon