Search code examples
kendo-mobile

Kendo UI Mobile forcing empty cell to not display in template


Is it possible to force an empty cell to not display in a template?

Currently my template is:

template = kendo.template("#if (title != null){#<span class=\"box favorable\">50</span><div class=\"title\">${ title }</div>#}else{}#");

However, if the else statement is called, it just displays an empty cell. I want the cell to not be displayed, instead of being an empty cell.


Solution

  • You need to include the table in the template to have a total control over it. For example, in your case, you need an approach like this:

    template = kendo.template("
      <table>
        # for (var i=0; i<rows.length;i++) { #
          #if (title != null){#
            <tr><td>
              <span class=\"box favorable\">50</span><div class=\"title\">#= title #</div>
            </td></tr>
          #}#
        # } #
      </table>
    ");