I am busy with an Angular2/Nativescript project where I am trying to replicate a HTML table... The way I am going about it is by adding two templates to a Listview, one for the headers and another for the content which is fetched from a REST API and will always be different. My only issue with this approach is left-aligning the headers and content, right now the columns doesn't start exactly under their headers but a bit to the right so it gets a bit confusing figuring out which column belongs to which header. Is it possible to do this at all in Nativescript? I also can't figure out how to add borders to separate the different rows and cells of my table/Listview... Any idea how I can go about doing this?
my code:
<ListView [items]="stockTransactions" [itemTemplateSelector]="templateSelector" class="list-group" backgroundColor="green">
<template nsTemplateKey="header" let-header="item">
<GridLayout rows="auto" columns="auto, *, *,, *" class="list-group">
<Label row="0" col="0" class="list-group-item" [text]="header.item1"></Label>
<Label row="0" col="1" class="list-group-item bg-primary" [text]="header.item2"></Label>
<Label row="0" col="2" class="list-group-item bg-primary" [text]="header.item3"></Label>
<Label row="0" col="3" class="list-group-item bg-primary" [text]="header.item4"></Label>
</GridLayout>
</template>
<template nsTemplateKey="cell" let-stockTransaction="item">
<GridLayout rows="auto" columns="*, *, *, *">
<Label row="0" col="0" textWrap="true" [text]="stockTransaction.Date | date" class="bg-primary list-group-item"></Label>
<Label row="0" col="1" textWrap="true" [text]="stockTransaction.TransactionType_Name" class="list-group-item"></Label>
<Label row="0" col="2" textWrap="true" [text]="stockTransaction.SupplierMaster_Name" class="list-group-item"></Label>
<Label row="0" col="3" textWrap="true" [text]="stockTransaction.Qty" class="list-group-item"></Label>
</GridLayout>
</template>
</ListView>
rowsandcolumnsyour snippet above has differentcolumnvalues - so they won't align very well depending on the content.