javascripthtmlangularjssortingngtable

Sorting custom template with Ng-Table in AngularJS


I followed this guide : Documentation

And I wrote this code :

<script type="text/ng-template" id="limiteRecDosExpl.html">
    <p sortable="'limiteRecDosExpl'">Limite réception fin<br />du dossier exploitant</p>
</script>

.....

<td filter="{ limiteRecDosExpl : 'text'}" header="'limiteRecDosExpl.html'" >
    <div style="word-wrap: break-word; width: 100%; overflow: hidden;">
        <span>{{row.limiteRecDosExpl | date:'shortDate'}}</span>
    </div>
</td>

The filter working great but the sortable directive inside the script tag not. I think is because data-title tag is missing but I need to break text inside the header with < br / > so I can't use it.

How can I sort my limiteRecDosExpl column ?


Solution

  • Finally fixed this.

    Just add an empty data-title into td tag and sort-indicator class into p tag in the template :

    <script type="text/ng-template" id="limiteRecDosExpl.html">
        <p class="sort-indicator">Limite réception fin<br />du dossier exploitant</p>
    </script>
    
    .....
    
    <td filter="{ limiteRecDosExpl : 'text'}" header="'limiteRecDosExpl.html'" data-title="''" >
        <div style="word-wrap: break-word; width: 100%; overflow: hidden;">
            <span>{{row.limiteRecDosExpl | date:'shortDate'}}</span>
        </div>
    </td>