Problems arising from the layout of the PrimeNG DataView component when used alongside Prime

I've been working with a PrimeNG DataView component that requires the use of PrimeFlex's flex grid CSS classes to set up the grid structure.

One of their examples includes the following instructions:

When in grid mode, the ng-template element should have a div element as a wrapper with a style class from PrimeFlex applied.

<p-dataView [value]="cars">
    <ng-template let-car pTemplate="listItem">
        <div>
            {{car.id}}
        </div>
    </ng-template>
    <ng-template let-car pTemplate="gridItem">
        <div class="p-col-12 p-md-3">
            {{car.year}}
        </div>
    </ng-template>
</p-dataView>

In my own code implementation, I followed the same structure. However, upon investigating, I noticed that the PrimeFlex CSS file did not contain the .p-grid and .p-col-* stylings as documented.

<p-dataView [value]="shows" layout="grid">
  <ng-template pTemplate="header"> List of shows </ng-template>

  <ng-template let-show pTemplate="gridItem">
    <div class="p-col-12 p-md-4">
      <div class="show-grid-item card">
        {{ show.title }}
      </div>
    </div>
  </ng-template>
</p-dataView>

I couldn't find the specific FlexGrid styles mentioned in the documentation within the primeflex.css file. If those styles are unavailable, is there a way to utilize the standard Grid styles provided by PrimeFlex for the DataView component?

Answer №1

For users of primeng 12 and primeflex, a temporary solution is to add the following code snippet to your style.css file until the bug is fixed in future versions:

.p-grid {
display: flex;
flex-wrap: wrap;
margin-right: -0.5rem;
margin-left: -0.5rem;
margin-top: -0.5rem;

}

Here is an example of HTML code incorporating this fix:

<p-dataView [value]="articuloViewList" layout="grid">
            <ng-template pTemplate="header">
                <p-dataViewLayoutOptions></p-dataViewLayoutOptions>
            </ng-template>
            <ng-template let-art pTemplate="listItem">
                <div>
                    {{art.artName}}
                </div>
            </ng-template>
            <ng-template let-art pTemplate="gridItem" #gridI>
                <div class="col-12 md:col-2">
                    {{art.artNombre}}
                </div>
            </ng-template>
        </p-dataView>

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

What is the reason why the swiper feature is malfunctioning in my React-Vite-TS application?

I encountered an issue when trying to implement Swiper in my React-TS project. The error message reads as follows: SyntaxError: The requested module '/node_modules/.vite/deps/swiper.js?t=1708357087313&v=044557b7' does not provide an export na ...

The return type in Typescript for dynamically generated return values

If I have a function in Typescript 2.0 like this: doSomething(): any { const apple: Apple = ... const pears: Pear[] = ... return { apple: apple, pears: pears } } I am aware that the function will always produce an object ...

How do I switch back and forth between displaying content as 'none' and 'block' using JQUERY?

Take a look at this code snippet. <div class="sweet-overlay" tabindex="-1" style="opacity: 1;display: none;"></div> Is there a way to switch the style attribute value from none to block and back? ...

Navigating the bitbucket pipeline to execute test cases for Angular 4 applications

Currently, I am facing an issue while integrating Bitbucket Pipeline for Angular 4. The problem lies in the fact that Chrome browser is not opening in the Bitbucket Pipeline console. My main objective is to figure out a way to execute test cases in the B ...

What is the process of generating a popup panel without relying on libraries, using JavaScript and CSS?

I'm currently working on creating a popup panel that is centered on the screen with rounded corners (scrollbars are unnecessary) using jQuery min, similar to this example: https://i.stack.imgur.com/0kYO6.png My progress so far: function (package) ...

Block-level declarations are commonly used in TypeScript and Asp.net MVC 5

In my asp.net mvc5 project, I decided to incorporate TypeScript. I created an app.ts file and installed the nuget-package jquery.TypeScript.DefinitelyTyped. Here is a snippet of the app.ts code: /// <reference path="typings/jquery/jquery.d.ts"/> cl ...

Struggling with eliminating the bottom margin on your website?

I can't figure out where this mysterious margin is coming from in the CSS - there's a consistent 30px of space at the bottom of each web page. Any assistance would be greatly appreciated. I know it's probably something simple, but my brain ...

typescript What is the best approach to searching within a nested array?

I am struggling to extract a specific value from a nested array within an array. Here is an example structure of my array: [ { ConcessionId: 1, ConcessionName: "Coyotes", KnownAs: [ { TeamId: 1, ...

Utilizing a local video file as a video background in HTML and CSS

I've hit a roadblock while attempting to set a video on my computer as the background. The video file is named "runbg.avi" and it resides in the same folder as my HTML and CSS files. After scouring through numerous websites, I encountered a couple of ...

Issue with jQuery fadeTo() not working after appendTo() function completes

I am facing a problem with the code below that is meant to create a carousel effect for my website. The main issue I am encountering is that the original fadeTo() function does not actually fade the elements, but rather waits for the fade time to finish an ...

Aligning variable width numbers within a div container

Currently experimenting with CSS to create a calendar design that mimics the look of a traditional paper calendar. One issue I've encountered is the alignment of numbers within boxes, especially when dealing with double digits. When displaying a sing ...

Guide on invoking an HTML event method from a parent component to a child component

I have the following parent component: JS import { Component, OnInit } from '@angular/core'; import { TaskService } from '../task.service'; import { ViewChild } from '@angular/core/src/metadata/di'; import { CreateNewTaskCom ...

Having an excess of 32 individual byte values

My current project involves developing a permission system using bitwise operators. A question came up regarding the limitation of having only 32 permissions in place: enum permissions { none = 0, Founder = 1 << 0, SeeAdmins = 1 << ...

inconsistency in button heights

I am currently working on a website project for one of my college courses and I have encountered an issue with the button heights in my slide show not matching up. I'm seeking advice or tips on how to align both buttons to have the same height. Can an ...

The size of the content in a JWT Bearer token may be restricted by certain external fire

We are encountering an issue related to the size of JWT tokens in our system. Our current setup includes an Angular front-end and an authentication service utilizing IdentityServer4. After successful authentication, the next step involves retrieving the u ...

Disabled screen rotation -> hidden background

I tried implementing a media query to "lock" the orientation on my mobile site, but unfortunately, my background image isn't displaying at all. After adding the media query, I included my stylesheet using the link: CSS body { padding:0; marg ...

Activate function on Ctrl + K in a React TypeScript project

I am currently developing a React TypeScript application using version v18.2.0. My goal is to trigger a function when the user simultaneously presses Ctrl + K. Here is the code snippet within my component: const keyDownHandler = (event: KeyboardEvent) =& ...

Issues are arising with CSS .not(selector) functionality when applied to a span element

One of the challenges I'm facing is formatting a header with a span tag that contains a date and some accompanying text. The goal is to make the text bold without affecting the formatting of the date. In my CSS file, I have tried using :not(cls) to t ...

Android mobile browser lacks visibility of certain elements

please provide a brief description of the image The issue I am facing is consistent across all mobile browsers, with the exception of Firefox. It also manifests in Windows Chrome devtools mode and when the device toolbar is activated. I came across a sim ...