Make sure PTable maintains a horizontal layout on any device with PrimeNG

When I view my Ptable on desktop or iPad, it looks like this:

https://i.stack.imgur.com/ONqZV.png

However, when I switch to a device like an iPhone X, it changes to this layout:

https://i.stack.imgur.com/H2q7j.png

I want the horizontal layout to display consistently on all devices, even though it may not look ideal. It's important for me to maintain the same appearance across different screens.

Below is the code snippet:

<p-table #dt [value]="pedidos" [rows]="10" [responsive]="true" [resizableColumns]="true"
           [paginator]="true" [rowsPerPageOptions]="[10,20,30,50,100]" (sortFunction)="customSort($event)"  
           [customSort]="true" columnResizeMode="expand" [columns]="selectedColumns" [reorderableColumns]="true"  
            [globalFilterFields]="['nroPedido','nroOrdenSap', 'nrocliente', 'cliente', 'estado', 'fechaEstado', 'totalLocal', 'total']">
            <ng-template pTemplate="caption">
              <div class="grid-container">
                <div class="grid-x">
                  <div class="medium-9 cell">
                    <div class="input-group">
                      <span class="input-group-label">
                        <i class="fa fa-search"></i>
                      </span>
                      <input type="text" class="input-group-field" size="50"
                        (input)="dt.filterGlobal($event.target.value, 'contains')" style="width:auto"
                        placeholder="{{Etiquetas.Buscar}}">
                    </div>
                  </div>
                  <div class="medium-3 cell">
                    <div style="text-align:left">
                      <p-multiSelect [options]="cols" [(ngModel)]="selectedColumns" optionLabel="header"
                        selectedItemsLabel="{0} {{Etiquetas.ColumnasSeleccionadas}}" [style]="{minWidth: '200px'}"
                        defaultLabel="{{Etiquetas.ElijaColumnas}}">
                      </p-multiSelect>
                    </div>
                  </div>
                </div>
              </div>
            </ng-template>

            <ng-template pTemplate="header" let-columns>
              <tr *ngIf="pedidos">
                <th pResizableColumn [ngStyle]="{'width': this.esMobile ? '10%' : '20%'}">
                  {{this.esMobile ?  '' : 'Acciones'}}
                
                </th>
                <th *ngFor="let col of columns" [pSortableColumn]="col.field" [ngStyle]="{'width': col.width}"
                  pResizableColumn pReorderableColumn>
                  {{col.header}}
                  <p-sortIcon [field]="col.field"></p-sortIcon>
                </th>
              </tr>
            </ng-template>

            <ng-template pTemplate="body" let-pedido let-columns="columns">
              <tr>
                <td>

                  <button *ngIf="pedido.editar" mat-icon-button matTooltip={{Etiquetas.Editar}}
                    routerLink="{{pedido.codigo}}">
                    <mat-icon color="primary">edit</mat-icon>
                  </button>

                  <button *ngIf="!pedido.editar" mat-icon-button matTooltip={{Etiquetas.Ver}}
                    routerLink="{{pedido.codigo}}">
                    <mat-icon color="primary">remove_red_eye</mat-icon>
                  </button>

                </td>
                <td *ngFor="let col of columns">
                  <span *ngIf="col.field !== 'estado' && col.field !== 'fechaEstado'">
                    {{ col.type ? col.type.transform(pedido[col.field]) : pedido[col.field] }}
                  </span>
                  <span *ngIf="col.field == 'fechaEstado'">
                    {{  pedido[col.field] }}
                  </span>

                  <span *ngIf="col.field == 'estado'" [ngClass]="cStatusClass(pedido.idEstado)" 
                    style="float:center;text-align:center;display:block">
                    {{ col.type ? col.type.transform(pedido[col.field]) : pedido[col.field] }}
                  </span>
                </td>
              </tr>
            </ng-template>
           
          </p-table>

Is there a specific property or CSS modification that can help me achieve this consistent horizontal layout across all devices?

Answer №1

After reviewing the HTML code, a simple adjustment was made to this property: [responsive]="false"

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Getting a blank request body error while receiving data from an Angular 4 application in Express

My express route is indicating that the body of the request being sent is empty, according to req.body. The main node file looks like this - var express = require('express'); var bluebird = require('bluebird') const bodyParser = requ ...

Maintaining the footer and bottom section of the webpage

I am facing an issue with the footer on my website . I want the footer to always stay at the bottom of the page, even when I dynamically inject HTML code using JavaScript. The footer displays correctly on the main page , but it does not work as intended on ...

The observed function remains untouched

In my code, I have an if condition inside a function that looks like this: public setOption() { setTimeout(() => { if (this.isCMode && !this.quest['isCompleted']) { this.toggleOption(false); } },window['TIME ...

Issue with Angular Datatable not displaying content when [dtTrigger] directive is included in the HTML table - Angular 14

Upon adding [dtTrigger] = "dtTrigger" to the HTML table, I encountered an issue where the datatable ceased rendering. All the features of the datatable were no longer visible on the page. Removing [dtTrigger] = "dtTrigger" from the HTML ...

Adding an icon to the contents of a specific column in Angular material

Struggling to figure out how to incorporate an icon into the data in the Status column using Angular material. Here is the markup of my page: <table mat-table [dataSource]="dataSource"> <ng-container *ngFor="let ...

Guide on creating and deploying an iOS API file onto a physical device with a Mac computer

I recently switched to using a Mac and have installed Xcode successfully, along with adding the platform for iOS. However, when I use adb devices, my iPhone device is not detected, but my Android device is recognized when connected. Additionally, when ru ...

When you click on an anchor tag, the divs do not automatically move to the top of the page

Encountering an issue with a rather straightforward website. It consists of a vertical scroll with a left side navigation. Whenever I click on a menu item, it fails to bring the corresponding section to the top of the page. I've experimented with a fe ...

What is the best way to conceal a broken image icon without sacrificing all of the stylesheet?

Can someone assist me in understanding and modifying this code? Here is the code snippet: <table> <tr> <td> <img src="" id="img" class="img" style="width:100%;height:200px;background-color:#ccc;border:2p ...

Combining Versioning with BundleConfig.cs: A Comprehensive Guide

Encountering a recurring issue where changes made to CSS or Javascript files do not reflect in client browsers unless they manually refresh the page with ctrl+F5. This poses a challenge, especially in a school system with numerous users who may not be awar ...

Creating a dynamic step animation with jQuery: A step-by-step guide

Struggling to find resources on how to animate a color wheel using jQuery? Want to create a spiraling effect by gradually revealing colors at 45-degree intervals, like a loading GIF spiral? I need it to cycle through the defined colors in order and then cl ...

Is there a way to develop a login form that retrieves information from a Google Sheet database?

Please help me with a solution. I have developed a registration form which effectively saves users' information in a Google Sheet. However, now I am yearning to create a login form that verifies the stored data and redirects the user to a different pa ...

Issues arise when attempting to create smooth animations with 100% transform translate across different web browsers

After uncovering an ancient piece of JS code that I had once shared for free use, I discovered that a CSS animation bug from 3 years ago is still causing trouble today. The issue involves animating an element from left:100%/transform: translateX(100%) or ...

What is the significance of using the @Input decorator on a component property in Angular?

Within this particular component, I discovered the @Input decorator connected to the variable. @Input() description: string; The variable "description" is then utilized in the HTML as an interpolation. <div>{{description}}</div> This prompt ...

Turn off the Antd Datepicker tooltip

I'm using Antd Datepicker in my website. We get an array of numbers representing disabled dates from an external api and show only the dates in the datepicker(no month, year etc). The date selection is for a monthly subscription and the user just sele ...

What is the correct way to accurately determine the width of a block being displayed with the flex-direction:column property?

For instance: HTML console.log($('.container').width()); // 600px as we defined in css. console.log($('.list').width()); // 600px console.log($('.box').eq('-1').position().left + $('.box').outerWidth( ...

Troubleshooting: Dealing with overflow problem in a span element containing an image tag

One issue I encountered involves overflow. A div is set to overflow: hidden, with all elements inside positioned absolutely. These elements consist of a span tag containing text and an image tag. An arrow allows control of the span tag moving forwards or b ...

Error encountered while running "ionic cordova run android" command

Recently, I revisited my Ionic Cordova app after a few months and encountered an unexpected dependency issue when attempting to make a minor adjustment to the app. Although the app previously functioned correctly, even reverting all changes failed to addre ...

What is the best way to hide only the rows in a table when it is clicked using JavaScript?

Is there a way to hide rows in these tables by clicking on the table head? I'm currently using bootstrap 5 so JQuery is not an option. <table class="table table-info table-bordered"> <thead id="tablea"> ...

Is the Mini Cart button in Woocommerce not aligned properly?

My website was functioning perfectly until yesterday. However, after updating some plugins, the Mini Cart dropdown button started to display in a weird and misaligned manner. Prior to the plugin updates, the button had the following style: background-col ...

What is the best way to utilize *ngSwitchWhen in a TypeScript environment?

I am currently working with Ionic2 and Angular2 and encountering an issue while trying to implement a segment using ngSwitchWhen. Unfortunately, the functionality is not working as expected and I am receiving an error message. How can I resolve this issue ...