super-elements / super-grid

0 stars 0 forks source link

Custom Renderers #5

Open gaurav21r opened 7 years ago

gaurav21r commented 7 years ago

Most of the HTML will be rendered according to #4 but in some cases we may need to output a cell a bit differently than the others.

The way hot-table does this is by using a <template> inside a <hot-column>. From http://handsontable.github.io/hot-table/examples/collapsing-columns.html

<template id="tpl" is="dom-bind">
    <hot-table width="570" height="500" datarows="{{ people }}" row-headers context-menu hidden-columns nested-headers="{{ settings.nestedHeaders }}" collapsible-columns="{{ settings.collapsibleColumns }}">
      <hot-column width="125" value="name" header="Full Name"></hot-column>
      <hot-column width="125" value="address" header="Address"></hot-column>
      <hot-column width="125" value="registered" header="Registered" type="date" date-format="YYYY-MM-DD"></hot-column>
      <hot-column width="125" value="balance" header="Balance" type="numeric">

       <!-- NOTICE THIS RENDERER -->
        <template data-hot-role="renderer" is="dom-template">
          <bold-renderer value="{{ value }}"></bold-renderer>
        </template>
       <!-- NOTICE THIS RENDERER -->

      </hot-column>
    </hot-table>
  </template>

Just need to checkout why they are using dom-bind rather than a simple <template>.

I think can do the same and it will be a very powerful system where users can use any HTML they want (including custom components) inside the <template>.