Create a sleek and innovative tree user interface in a single line with the power of Angular and fxF

I created a tree with parent and child nodes, but I'm facing an issue where the positions of the checkboxes are not aligned in a straight line. Here is my code snippet:

           
<mat-tree-node *matTreeNodeDef="let node" matTreeNodeToggle>
    <div>
        <button mat-icon-button disabled></button>
        <td fxFlex="150px" fxLayoutAlign="start">
            {{node.title}}
        </td> 
        <td fxFlex="100px" fxLayoutAlign="center">
            <mat-checkbox [(ngModel)]="node.can_view"></mat-checkbox>
        </td> 
        <td fxFlex="100px" fxLayoutAlign="center">
            <mat-checkbox [(ngModel)]="node.can_insert"></mat-checkbox>
        </td>
        <td fxFlex="100px" fxLayoutAlign="center">
            <mat-checkbox [(ngModel)]="node.can_update"></mat-checkbox>
        </td>
        <td fxFlex="100px" fxLayoutAlign="center">
            <mat-checkbox [(ngModel)]="node.can_delete"></mat-checkbox>
        </td>
        <td fxFlex="100px" fxLayoutAlign="center">
            <mat-checkbox [(ngModel)]="node.can_export"></mat-checkbox>
        </td> 
        <td fxFlex="100px" fxLayoutAlign="center">
            <mat-checkbox [(ngModel)]="node.can_upload"></mat-checkbox>
        </td>
        <td fxFlex="130px" fxLayoutAlign="center">
            <mat-checkbox [(ngModel)]="node.need_approve"></mat-checkbox>
        </td>
    </div>
</mat-tree-node>
<mat-nested-tree-node *matTreeNodeDef="let node; when: hasChild">

    <div class="mat-tree-node">
        <button mat-icon-button matTreeNodeToggle>
            <mat-icon>
                {{tc.isExpanded(node) ? 'keyboard_arrow_down' : 'chevron_right'}}
            </mat-icon>
        </button>
        <tr >
            <td fxFlex="150px" fxLayoutAlign="start">
                {{node.title}}
          </td> 
          <td fxFlex="100px" fxLayoutAlign="center">
              <mat-checkbox [(ngModel)]="node.can_view" (change)="update('can_view',node.id,$event.checked)" ></mat-checkbox>
          </td> 
          <td fxFlex="100px" fxLayoutAlign="center">
              <mat-checkbox [(ngModel)]="node.can_insert" (change)="update('can_insert',node.id,$event.checked)"></mat-checkbox>
          </td>
          <td fxFlex="100px" fxLayoutAlign="center">
              <mat-checkbox [(ngModel)]="node.can_update" (change)="update('can_update',node.id,$event.checked)"></mat-checkbox>
          </td>
          <td fxFlex="100px" fxLayoutAlign="center">
              <mat-checkbox [(ngModel)]="node.can_delete" (change)="update('can_delete',node.id,$event.checked)"></mat-checkbox>
          </td>
          <td fxFlex="100px" fxLayoutAlign="center">
              <mat-checkbox [(ngModel)]="node.can_export" (change)="update('can_export',node.id,$event.checked)"></mat-checkbox>
          </td> 
          <td fxFlex="100px" fxLayoutAlign="center">
              <mat-checkbox [(ngModel)]="node.can_upload" (change)="update('can_upload',node.id,$event.checked)"></mat-checkbox>
          </td>
          <td fxFlex="130px" fxLayoutAlign="center">
              <mat-checkbox [(ngModel)]="node.need_approve" (change)="update('need_approve',node.id,$event.checked)"></mat-checkbox>
          </td>     
      </tr>
    </div>
    <div style="margin-left:1em" [hidden]="!tc.isExpanded(node)">
        <ng-container matTreeNodeOutlet></ng-container>
    </div>
</mat-nested-tree-node>
</mat-tree>
</tbody>

In my project, I have implemented a tree structure with parent-child relationships, but I am looking to align the checkboxes in a single line.

Answer №1

The solution you're seeking is right here: MatTreeNodePadding. This handy feature allows you to set the padding for each level using matTreeNodePaddingIndent. By default, it follows the material design menu sub-menu specifications with a 40px indent.

To implement this, simply include it in your mat-tree-node as shown below:

<mat-tree-node ... matTreeNodePadding matTreeNodePaddingIndent="0">
 ...
</mat-tree-node>

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

Using a foreach loop to showcase data in a table

My goal is to utilize the GitHub API to showcase all the issues present in my repository in a neat table format on my website. Despite my best efforts, I am facing difficulties in generating the table using a foreach loop. Below is the PHP code I am curr ...

Experiment with altering the layout of certain navigation bars

I am currently attempting to customize the background color and text color for specific HTML components. Within my project, there are 3 navigation bars. I aim to establish a default color for all nav bars while also altering the specific color of one of t ...

Which html parsing tool is capable of processing encoding?

The journey begins -- I have a file saved on my computer that is an HTML page. When I view it in a regular web browser, the correct characters are displayed regardless of the encoding used. Then comes the challenge -- my task is to load the same file, par ...

The text enclosed by a span located inside a div and identified by xpath

I am struggling to extract text from a span nested within another text in a div (highlighted in the image). https://i.sstatic.net/8uIWz.png This snippet of code is relevant ... <div id="groupBlock3"> <div class="groupBlockTitle& ...

"Troubleshooting issue: Module fails to reload following JSON.parse error

For QA testing purposes, we have a test page that allows our QA team to replicate server behavior by passing JSON to a mock service. Everything functions correctly when valid JSON is used, but if invalid JSON is provided, an error is returned - which is ex ...

Error 404: Angular 2 reports a "Not Found" for the requested URL

I am currently in the process of integrating an Angular 2 application with a Java Spring Boot backend. As of now, I have placed my Angular 2 files under src/main/resources/static (which means that both the Angular and Spring apps are running within the sam ...

Sliding divider across two div containers with full width

Seeking a JavaScript/jQuery function for a full page slider functionality. The HTML structure I'm working with is as follows: My objectives are twofold: Both slide1 and slide2 should occupy the full width of the page. Additionally, I am looking for ...

Execute MySQL query when the content of an HTML text field changes

My goal is to check if the value entered in an input text box matches any rows in a database. I want the DB to be searched when text is typed into the input field. <input type='text' name='barcode'> I would like it to search the ...

Using a series of identical divs to dynamically update the image URL

Greetings! I am a newcomer to the world of web development and I have decided to hone my skills by creating a small website for my mother! My goal is to replicate a specific div multiple times while changing only the image URL and the heading caption. < ...

Is there a way to keep my fixed footer container from moving while zooming in and out on a webpage

Is there a way to prevent the bottom text from shifting when zoomed in or out on the page? The rest of the content remains stable, but due to using position:absolute for this section to stay at the bottom of another div (content), it causes movement. #con ...

Have you noticed the issue with Angular's logical OR when using it in the option attribute? It seems that when [(ngModel)] is applied within a select element, the [selected] attribute is unable to change

Within the select element, I have an option set up like this: <option [selected]=" impulse === 10 || isTraining " value="10">10</option> My assumption was that when any value is assigned to impulse and isTraining is set to true, the current o ...

What is the best way to align text in the middle of a card using bootstrap?

I crafted a code to display cards using Bootstrap 4. My goal now is to center all the text inside the card, but I'm facing challenges in achieving this. I attempted to apply "text-center" to the entire section. I also tried using "d-flex" and justify ...

Utilize ngFor within a ng-template to display dynamic content in a table structure

Currently, I am attempting to loop through a list that is obtained from an API request and then populate the data into a table. The issue I am facing is that this table exists within an ng-template tag, and I am unsure of how to manage this situation. Thi ...

Count the number of checked checkboxes by looping through ngFor in Angular

My ngFor loop generates a series of checkboxes based on the X number of items in childrenList: <div *ngFor="let child of childrenList; let indice=index"> <p-checkbox label="{{child.firstname}} {{child.lastname}}" binary=&qu ...

Animating a CSS overlay

My goal is to design an overlay using the following HTML and CSS code snippets div.relative { position: relative; width: 400px; height: 200px; border: 3px solid #73AD21; } div.absolute { position: absolute; top: 50%; right: 0; width: 20 ...

What is the best way to calculate the total sum of the first element in each index of an array when using ng

I am looking to calculate the sum of the first elements from all indexes of an array using ng-repeat in AngularJS. My goal is to declare a variable and increment its value with each iteration of ng-repeat, then display that variable at the end. Below is ...

What is the best way to make a table fill 100% of the available height

Is this a Repetitive Question? How to stretch an HTML table to 100% of the browser window height? Just like the title says, I am looking for a way to make my table element stretch to 100% height even when the content does not entirely fill the page&ap ...

incorporate partial html into nodeJS & Jade using AJAX requests

Is there a smart method to load just a segment of a page using Node.js and Jade?: I'm in the process of creating a music blog and I want to incorporate a seamless player at the top of each page. The goal is for the player to keep playing without inte ...

What is the reason WebPack is missing from the Visual Studio 2017 Dot Net Core 2.1 & Angular template?

Webpack 4 has introduced numerous enhancements, such as increased speed of up to 98% with minimal configuration. Interestingly, while Visual Studio 2017 with dot net core + angular 4 included webpack in the template, a recent project created in VS 2017 w ...

Unusual activity observed in HTML5 contenteditable functionality

Within a list item, I have a span element. <ul> <li>text part 1 <span class="note">this is a note</span> text part 2 </li> <li>text part 3</li> </ul> When you double click on th ...