LevanIlashvili
LevanIlashvili

Reputation: 26

Knockout.js SimpleGrid doesn't render correctly

I was trying to modify Knockout.js simpleGrid , so that I could put hyperlink in cell content. I replaced

 this.addItem = function() {
    this.items.push({ name: "New item", sales: 0, price: 100 });
};

with

 this.addItem = function() {
    this.items.push({ name: "<a href='#'> click me </a>", sales: 0, price: 100 });
};

hoping, that after hitting "Add item" button, a new item would appear, with link in it's name. Unfortunately, it rendered as pure text and I got this in new item's name

 <a href='#'>click me</a>

So, can anybody help with this? I want to put a hyperlink inside grid cell

Upvotes: 0

Views: 682

Answers (1)

RP Niemeyer
RP Niemeyer

Reputation: 114792

The template in the simpleGrid plugin uses the text binding on the td. This will set the innerText of the cell, so any HTML content would be escaped.

You would have modify the template (called "ko_simpleGrid_grid") in the simple grid plugin to either use the html binding rather than text or to actually render specific content that you want.

Upvotes: 2

Related Questions