angular-generic-table
angular-generic-table copied to clipboard
Feature request: Define columns in templates
It would be nice to define the columns in templates the way https://github.com/swimlane/ngx-datatable supports it.:
<ngx-datatable>
<ngx-datatable-column name="Name">
<template let-column="column" ngx-datatable-header-template>
Holla! {{column.name}}
</template>
<template let-value="value" ngx-datatable-cell-template>
Hi: <strong>{{value}}</strong>
</template>
</ngx-datatable-column>
<ngx-datatable-column name="Gender">
<template let-column="column" let-sort="sortFn" ngx-datatable-header-template>
<span (click)="sort()">{{column.name}}</span>
</template>
<template let-row="row" let-value="value" ngx-datatable-cell-template>
My name is: <i [innerHTML]="row['name']"></i> and <i>{{value}}</i>
<div>{{joke}}</div>
</template>
</ngx-datatable-column>
<ngx-datatable-column name="Age">
<template let-value="value" ngx-datatable-cell-template>
<div style="border:solid 1px #ddd;margin:5px;padding:3px">
<div style="background:#999;height:10px" [style.width]="value + '%'"></div>
</div>
</template>
</ngx-datatable-column>
</ngx-datatable>
That way you can i18n column names and define column templates in the place you want the table to show up.
Hmm well, the thought was originally to simplify and minimize the markup and avoid "unnecessary clutter" as well as being able to create a table purely by configuration. Adding templates adds complexity which I'm not sure we want, but then again I'm not fully happy with how we currently support custom components inside the table and using templates together with ngTemplateOutlet
might be useful in that case. Regarding support for i18n and translations, it is on the todo list but I don't think we'll introduce templates just to solve that. But'll think about and see if I can come up with another use case that might require templates.