Search code examples
htmlkendo-uikendo-mvvm

Kendo MVVM template for table missing headers


I have a table that's bound to a datasource and retrieving data as expected. However, the heading tags are not displaying. What am I missing?

HTML

<div id="productResults">
<table style="width: 50%" data-bind="source: Products" data-template="productsTemplate">
    <tr>
        <th>Product ID</th>
        <td>Product Name</td>
    </tr>
</table>

<script id="productsTemplate" type="text/x-kendo-template">
    <tr>
        <td>#:ProductID#</td>
        <td>#:ProductName#</td>
    </tr>
</script>

OUTPUT enter image description here


Solution

  • Shift your bindings from Table to tbody tag like this

    try changing for header only

    <thead>
        <th>Product ID</th>
        <th>Product Name</th>
    </thead>
    

    OR

    <table style="width: 50%" >
        <thead>
            <th>Product ID</th>
            <th>Product Name</th>
        </thead>
        <tbody data-bind="source: Products" data-template="productsTemplate">
        </tbody>
    </table>