Base solution for your next web application
Open Closed

Apply-same-design-from-p-table-on-p-treeTable Angular #12398


User avatar
0
[email protected] created

Hi,

how is it possible to apply the same styling with the dotted row seperator and everything else from the p-table on p-treeTable. Currently it looks like in the Screenshot. First Screenshot is the default "ASP.NET Zero Angular Metronic Theme p-table" and second screenshot is the p-treeTable

Implementation:

           <p-treeTable
              #dataTable
              class="p-table"
              [value]="files"
              [columns]="cols"
              [lazy]="true"
              [loading]="loading"
              [totalRecords]="totalRecords"
              [rows]="10"
              [rowsPerPageOptions]="[5,10,20,50]"
              [sortMode]="'single'"
              selectionMode="single"
              (onNodeSelect)="onBusinessCaseSelect($event)"
              (onLazyLoad)="loadBusinessCases($event)"
              [scrollable]="true"
              ScrollWidth="100%"
              
              [tableStyle]="{'min-width': '50rem'}"
              >
     &lt;p-table #dataTable (onLazyLoad)=&quot;getArticles($event)&quot; [value]=&quot;primengTableHelper.records&quot;
                             [rows]=&quot;primengTableHelper.defaultRecordsCountPerPage&quot; [paginator]=&quot;false&quot; [lazy]=&quot;true&quot;
                             [scrollable]=&quot;true&quot; scrollWidth=&quot;100%&quot;
                             [tableStyle]=&quot;{&#39;min-width&#39;: &#39;50rem&#39;}&quot;
                             [resizableColumns]=&quot;primengTableHelper.resizableColumns&quot;&gt;

                        &lt;!-- Table Header --&gt;
                        &lt;ng-template pTemplate=&quot;header&quot;&gt;
                            &lt;tr&gt;
                                &lt;th style=&quot;width: 130px&quot; [hidden]=&quot;!isGrantedAny(&#39;Pages.Articles.Edit&#39;, &#39;Pages.Articles.Delete&#39;)&quot;&gt;
                                    {{l('Actions')}}
                                &lt;/th&gt;
                                &lt;th style=&quot;width: 150px&quot; pSortableColumn=&quot;articleName&quot;&gt;
                                    {{l('ArticleName')}}
                                    &lt;p-sortIcon field=&quot;articleName&quot;&gt;&lt;/p-sortIcon&gt;
                                &lt;/th&gt;
                                &lt;th style=&quot;width: 100px&quot; pSortableColumn=&quot;unit&quot;&gt;
                                    {{l('Unit')}}
                                    &lt;p-sortIcon field=&quot;unit&quot;&gt;&lt;/p-sortIcon&gt;
                                &lt;/th&gt;
                                &lt;th style=&quot;width: 300px&quot; pSortableColumn=&quot;description&quot;&gt;
                                    {{l('Description')}}
                                    &lt;p-sortIcon field=&quot;description&quot;&gt;&lt;/p-sortIcon&gt;
                                &lt;/th&gt;
                                &lt;th style=&quot;width: 300px&quot; pSortableColumn=&quot;articleGroup&quot;&gt;
                                    {{l('ArticleGroup')}}
                                    &lt;p-sortIcon field=&quot;articleGroup&quot;&gt;&lt;/p-sortIcon&gt;
                                &lt;/th&gt;
                            &lt;/tr&gt;
                        &lt;/ng-template&gt;

                        &lt;!-- Table Body --&gt;
                        &lt;ng-template pTemplate=&quot;body&quot; let-record=&quot;$implicit&quot; let-i=&quot;rowIndex&quot;&gt;
                            &lt;tr&gt;
                                &lt;td style=&quot;width: 130px&quot; [hidden]=&quot;!isGrantedAny(&#39;Pages.Articles.Edit&#39;, &#39;Pages.Articles.Delete&#39;)&quot;&gt;
                                    &lt;div class=&quot;btn-group dropdown&quot; dropdown container=&quot;body&quot;&gt;
                                        &lt;button class=&quot;dropdown-toggle btn btn-sm btn-primary&quot; dropdownToggle&gt;
                                            &lt;i class=&quot;fa fa-cog&quot;&gt;&lt;/i&gt; &lt;span class=&quot;caret&quot;&gt;&lt;/span&gt; {{l("Actions")}}
                                        &lt;/button&gt;
                                        &lt;ul class=&quot;dropdown-menu&quot; *dropdownMenu&gt;
                                            &lt;li&gt;
                                                &lt;a *ngIf=&quot;permission.isGranted(&#39;Pages.Articles.Edit&#39;)&quot;
                                                   class=&quot;dropdown-item&quot;
                                                   [routerLink]=&quot;[&#39;/app/main/articles/articles/createOrEdit&#39;]&quot;
                                                   [queryParams]=&quot;{id: record.article.id}&quot;&gt;
                                                    {{l('Edit')}}
                                                &lt;/a&gt;
                                            &lt;/li&gt;
                                            &lt;li&gt;
                                                &lt;a class=&quot;dropdown-item&quot; href=&quot;javascript:;&quot;
                                                   *ngIf=&quot;permission.isGranted(&#39;Pages.Articles.Delete&#39;)&quot;
                                                   (click)=&quot;deleteArticle(record.article)&quot;&gt;
                                                    {{l('Delete')}}
                                                &lt;/a&gt;
                                            &lt;/li&gt;
                                        &lt;/ul&gt;
                                    &lt;/div&gt;
                                &lt;/td&gt;
                                &lt;td style=&quot;width: 150px&quot;&gt;
                                    &lt;span class=&quot;p-column-title&quot;&gt;{{l('ArticleName')}}&lt;/span&gt;
                                    {{record.article.name}}
                                &lt;/td&gt;
                                &lt;td style=&quot;width: 100px&quot;&gt;
                                    &lt;span class=&quot;p-column-title&quot;&gt;{{l('Unit')}}&lt;/span&gt;
                                    {{record.unitName}}
                                &lt;/td&gt;
                                &lt;td style=&quot;width: 300px&quot;&gt;
                                    &lt;span class=&quot;p-column-title&quot;&gt;{{l('Description')}}&lt;/span&gt;
                                    {{record.article.description}}
                                &lt;/td&gt;
                                &lt;td style=&quot;width: 300px&quot;&gt;
                                    &lt;span class=&quot;p-column-title&quot;&gt;{{l('ArticleGroup')}}&lt;/span&gt;
                                    {{record.articleGroupName}}
                                &lt;/td&gt;
                            &lt;/tr&gt;
                        &lt;/ng-template&gt;
                    &lt;/p-table&gt;
                    




       &lt;p-treeTable
          #dataTable
          class=&quot;p-table&quot;
          [value]=&quot;files&quot;
          [columns]=&quot;cols&quot;
          [lazy]=&quot;true&quot;
          [loading]=&quot;loading&quot;
          [totalRecords]=&quot;totalRecords&quot;
          [rows]=&quot;10&quot;
          [rowsPerPageOptions]=&quot;[5,10,20,50]&quot;
          [sortMode]=&quot;&#39;single&#39;&quot;
          selectionMode=&quot;single&quot;
          (onNodeSelect)=&quot;onBusinessCaseSelect($event)&quot;
          (onLazyLoad)=&quot;loadBusinessCases($event)&quot;
          [scrollable]=&quot;true&quot;
          ScrollWidth=&quot;100%&quot;
          
          [tableStyle]=&quot;{&#39;min-width&#39;: &#39;50rem&#39;}&quot;
          &gt;
          &lt;!-- Table Header --&gt;
          &lt;ng-template pTemplate=&quot;header&quot; let-columns&gt;
            &lt;tr&gt;
              &lt;th *ngFor=&quot;let col of columns&quot; [ttSortableColumn]=&quot;col.field&quot;&gt;
                {{ col.header }}
                &lt;p-treeTableSortIcon [field]=&quot;col.field&quot;&gt;&lt;/p-treeTableSortIcon&gt;
              &lt;/th&gt;
            &lt;/tr&gt;
          &lt;/ng-template&gt;

          &lt;!-- Table Body --&gt;
          &lt;ng-template pTemplate=&quot;body&quot; let-rowNode let-rowData=&quot;rowData&quot; let-columns=&quot;columns&quot;&gt;
            &lt;tr [ttSelectableRow]=&quot;rowNode&quot;&gt;
              &lt;td *ngFor=&quot;let col of columns; let i = index&quot;&gt;
                &lt;p-treeTableToggler [rowNode]=&quot;rowNode&quot; *ngIf=&quot;i === 0&quot;&gt;&lt;/p-treeTableToggler&gt;
                {{ rowData[col.field] }}
              &lt;/td&gt;
            &lt;/tr&gt;
          &lt;/ng-template&gt;

          &lt;!-- Empty Message --&gt;
          &lt;ng-template pTemplate=&quot;emptymessage&quot;&gt;
            &lt;tr&gt;
              &lt;td [attr.colspan]=&quot;cols.length&quot; class=&quot;text-center&quot;&gt;
                {{ 'NoRecordsFound' | localize }}
              &lt;/td&gt;
            &lt;/tr&gt;
          &lt;/ng-template&gt;
        &lt;/p-treeTable&gt;
Markdown is supported
Copy & paste or drag & drop images (max 30 MB per image)

No answer yet!