Customize expanded and collapsed icons in PrimeNG treeTable component

I am currently utilizing the treeTable component from primeNG. My query is regarding how to customize the default expand and collapse icons.

Although I attempted to make adjustments, I am uncertain if my approach is correct. What I aim to achieve is simply replacing the built-in expand/collapse icons with plus/minus symbols. Can someone guide me on how to proceed?

My attempts at customization have not yielded the desired results so far.

https://i.sstatic.net/fJuTK.png

demo

Answer №1

Below are the steps to update the icons using CSS:

::ng-deep .pi-chevron-right:before {
  content: "\e90d";
}

::ng-deep .pi-chevron-down:before {
  content: "\e90f";
}

Check out the demo for reference.

Answer №2

For those utilizing primeng 16, a useful template customization can be implemented as shown below:

    <ng-template pTemplate="togglericon" let-open>
      <span *ngIf="open" class="pi pi-minus"></span>
      <span *ngIf="!open" class="pi pi-plus"></span>
    </ng-template>

This code snippet should be inserted within your p-treetable element.
The 'let-open' syntax provides access to the implicit boolean value of the context, which can be renamed as desired.

While this customization is confirmed to work on primeng 16, its compatibility with earlier versions has not been verified.
Detailed information on template customizations can be found in the API documentation:

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

Customize the background color of highlighted text using HTML and jQuery

Recently, I modified an existing code to divide plain text into four classes by selecting a portion of the text and coloring it. Afterwards, I extracted the text of each class and stored it in my database. While this code works well, I am looking for a way ...

Placing a component within a .jsx file instead of utilizing a .css file for positioning

Seeking a way to position a component within a .jsx-file, rather than a .css-file, to accommodate multiple instances of the same component performing various tasks on different parts of the page. Avoiding duplication of files with minor CSS class changes, ...

The attribute 'getValue' is not a valid property for the data type 'Subject<boolean>'

Currently, I am working with Angular2 and have a BehaviorSubject. isOpen$: Subject<boolean> = new BehaviorSubject<boolean>(true); When I try to retrieve the latest value using: isOpen$.getValue() It functions correctly, however, there is a ...

How to create a calendar selection input using PHP?

Before I start writing the code myself, I am searching to see if there is already a solution available or if someone has previously outsourced the code. Below is an example of my date selection: https://i.sstatic.net/KqIDH.png I want to create a feature ...

Trouble with insertAdjacentHTML not functioning properly on newly created element

I need to add a table below an h1 element that has the id of pageHeading. The hardcoded HTML for the h1 is: <h1 id="pageHeading">Table</h1> const pageHeading = document.querySelector("#pageHeading") The JavaScript code to c ...

What is the best way to create an input field along with a span element using the :before pseudo class?

My first question on StackOverflow is regarding adding a pseudo-class before an input type button for animation (http://codepen.io/anon/pen/emodKG). I understand that it's not possible to directly add something before an input, so I attempted to inclu ...

Do not apply transitions to a pseudo-class in CSS

Can a pseudo-class with the same property as another pseudo-class be prevented from being transitioned? Take a look at this example code: button { height: 50px; width: 150px; font-size: 20px; color: white; border: none; background-color: b ...

Using Xpath to target elements based on attributes and retrieving the values of another attribute

I am trying to extract the datetime attribute value from each li element that contains an attribute type with the value of standard. However, my current code is resulting in an error. Here is the snippet: <li datetime="2019-06-03T14:45" offset="-135" t ...

Angular and Firebase: Incorporating user feedback into the frontend data structure

I am new to using Angular and Firebase. My current approach involves logging in with Angular to my Firebase backend and then viewing the response in the console to see all the keys associated with a firebase user. However, I am looking for a way to link th ...

Comparison of valueChanges between ReactiveForms in the dom and component级主动形

Is there a method to determine if the change in valueChanges for a FormControl was initiated by the dom or the component itself? I have a scenario where I need to execute stuff() when the user modifies the value, but I want to avoid executing it if the v ...

Showing php outputs within a container

I want to outline my goal in detail. I have a setup with 3 pages: index.html, form.html, and result.php. By using jQuery, when the button on index.html is clicked, form.html is loaded inside a div within index.html. Upon submitting form.html, it calls resu ...

Formatting Strings in JavaScript when saving as a .txt file with proper indentation

Utilizing Angular and TypeScript/JavaScript for testing purposes. Each row has been formatted with a newline at the end of the code. formattedStr += car.Name + ' | ' + car.Color + ' | ' + car.Brand + '\r\n' The da ...

Transfer data to ASP.NET MVC using AJAX and FormData

I am working with a simple model: public class MyModel { public string Description { get; set; } public HttpPostedFileBase File {get; set; } } and I have an MVC action for uploading data: [HttpPost] public ActionResult Upload(List<MyModel> d ...

Visual feedback: screen flashes upon clicking to add a class with jQuery

I have successfully added a click event to my pricing tables in order to apply an animation class on mobile devices. However, I am facing an issue where every time I click on a pricing option on my iPhone, the screen flashes before the class is applied. Is ...

The recent update from Angular version 5.2 to 7 has caused issues with Post methods

An issue has occurred with the type mismatch in the error handling function. It seems that the argument provided is not compatible with the expected parameter type within the Observable structure. GetFullAddress(addressModel: FullAddr ...

Determine with jQuery whether the img src attribute is null

My HTML structure is as follows: <div class="previewWrapper" id="thumbPreview3"> <div class="previewContainer"> <img src="" class="photoPreview" data-width="" data-height=""><span>3</span> </div> </div> ...

Sleek Dialog Boxes with Bootstrap 4 - Bootbox Modal

Within the structure of my webpage, there resides a table containing various elements. One specific cell within this table holds a link that triggers jQuery scripts upon being clicked. An example action initiated by clicking this link is displaying a Boots ...

Prevent assigning values to rxjs observables recursively

I am seeking suggestions on how to enhance the code provided below. I will outline the issue and present my current solution, which I aim to refine. The code is written in Angular 4 (TS). herelistOfItems$: Observable<Array<Item>>; // Fetchin ...

What is the best way to selectively remove and then later reinsert two items from an array in

I am facing a scenario where I have two buttons and an array to work with. The buttons are labeled "OR" and "AND", and the array consists of 7 items in a Dropdown list. When the user clicks on the "OR" button, it should remove 2 items from the array. Co ...

Explore the limitless possibilities of using jQuery Superscrollorama with fixed backgrounds

I am looking to achieve a scrolling effect with multiple elements, specifically three pictures in this case. While it is easy to implement scrolling, my goal is to keep the background fixed during the scroll event and have it move once the scrolling is co ...