Skip to content
This repository was archived by the owner on Dec 15, 2025. It is now read-only.
This repository was archived by the owner on Dec 15, 2025. It is now read-only.

Componente p-table #27

Open
Open

Description

@Osva2021

Saludos a todos, soy principiante tanto en angular como en esta librería, Como puedo aumentar o disminuir la altura de una fila en el componente p-table ?, gracias a todos.

Activity

  1. Mukarram990 commented on Sep 3, 2024

    @Mukarram990

    You can use [styleClass] property to increase or decrease the size of rows as listed on the primeng website PRIMENG

    HTML:

    <div class="card">
        <div class="flex justify-content-center mb-3">
            <p-selectButton 
                [options]="sizes" 
                [(ngModel)]="selectedSize" 
                [multiple]="false" 
                optionLabel="name" 
                optionValue="class" />
        </div>
        <p-table [value]="products" [tableStyle]="{ 'min-width': '50rem' }" [styleClass]="selectedSize.class">
            <ng-template pTemplate="header">
                <tr>
                    <th>Code</th>
                    <th>Name</th>
                    <th>Category</th>
                    <th>Quantity</th>
                </tr>
            </ng-template>
            <ng-template pTemplate="body" let-product>
                <tr>
                    <td>{{ product.code }}</td>
                    <td>{{ product.name }}</td>
                    <td>{{ product.category }}</td>
                    <td>{{ product.quantity }}</td>
                </tr>
            </ng-template>
        </p-table>
    </div>
    

    TS:

    import { Component } from '@angular/core';
    import { Product } from '@domain/product';
    import { ProductService } from '@service/productservice';
    import { TableModule } from 'primeng/table';
    import { SelectButtonModule } from 'primeng/selectbutton';
    import { CommonModule } from '@angular/common';
    
    @Component({
        selector: 'table-size-demo',
        templateUrl: 'table-size-demo.html',
        standalone: true,
        imports: [TableModule, SelectButtonModule, CommonModule],
        providers: [ProductService]
    })
    export class TableSizeDemo {
        products!: Product[];
    
        sizes!: any[];
    
        selectedSize: any = '';
    
        constructor(private productService: ProductService) {}
    
        ngOnInit() {
            this.productService.getProductsMini().then((data) => {
                this.products = data;
            });
    
            this.sizes = [
                { name: 'Small', class: 'p-datatable-sm' },
                { name: 'Normal', class: '' },
                { name: 'Large',  class: 'p-datatable-lg' }
            ];
        } 
    }
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions