Create dynamic tree grid with expande / collapse selected rows and select checkbox for the entire row select/deselect in Salesforce lightning web component LWC | how to create tree grid with expanded/collapsed section for the entire row marked as select / deselect with checkbox in Salesforce LWC

6,792 views


Hey guys, today in this post we are going to learn about How to Create dynamic tree grid with expanded/collapsed selected rows and select checkbox for the entire row select/deselect in Salesforce lightning web component LWC.

A lightning-tree-grid component displays hierarchical data in a table. Its appearance resembles lightning-datatable since it implements lightning-datatable internally, with the exception that each row in the table can be expanded to reveal a nested group of items. Rows that contain nested data display a chevron icon to denote that they can be expanded or collapsed. This visual representation is useful for displaying structured data such as account hierarchy or forecasting data. To know more details about lightning-tree-grid, Click Here..

This component implements the tree grid blueprint in the Lightning Design System.

Note:: – You will get an email, so put correct email and mobile number and BEGIN YOUR JOURNEY from Today!

 

Inline editing and sorting of columns are not supported.

Supported features include.

  • Displaying and formatting of columns with appropriate data types
  • Header-level actions
  • Row-level actions
  • Resizing of columns
  • Selecting of rows
  • Text wrapping and clipping

 

 

Files we used to create lightning tree grid in Salesforce LWC →

lwcTreeGrid.html LWc HTML File Template HTML file to display expande/collapse selected rows in Salesforce Lightning Web Component (LWC)
lwcTreeGrid.js LWC JavaScript File It’s hold getCurrentExpandedRows action method to retrieve the list of rows in Salesforce LWC.
sampleData.js LWC JavaScript File It’s export the gridData for expanded rows in Salesforce LWC.
lwcTreeGrid.css Style CSS It’s fill the background color on the page in Salesforce LWC.
lwcTreeGrid.js-meta.xml XML Meta File It is used to where this lightning web component file you want to display as lightning__AppPage, lightning__RecordPage, lightning__HomePage.

 

Final Output →

tree grid dynamic expand collapse in lwc -- w3web.net
 

 

You can download file directly from github by Click Here.

 
 

Other related post that would you like to learn in Salesforce

Note:: – You will get an email, so put correct email and mobile number and BEGIN YOUR JOURNEY from Today!
 
 

 

Create Lightning Web Component HTML →

Step 1:- Create Lightning Web Component : lwcTreeGrid.html

SFDX:Lightning Web Component >> New >> lwcTreeGrid.html

lwcTreeGrid.html [Lightning Web Component HTML]

  1.    <template>
  2. <lightning-card>
  3.     <div class="slds-p-around_medium">   
  4. <h3 class="slds-text-heading_medium"><lightning-icon icon-name="custom:custom92" size="small"></lightning-icon> <strong style="color:#270086; font-size:13px; margin-right:5px;"> Tree Grid:- Displays a hierarchical view of data in a table in Lightning Web Component (LWC) </strong></h3>
  5. <br/><br/>
  6.  
  7.     <div class="slds-p-around_medium lgc-bg">
  8.         <lightning-tree-grid
  9.             columns={gridColumns}
  10.             data={gridData}
  11.             key-field="name"
  12.         ></lightning-tree-grid>
  13.  
  14.         <br/>
  15.    <br/>
  16.    <!--Start RelatedTopics Section-->
  17. <div style="border:1px #ddd solid; padding:10px; background:#eee; margin:40px 0;">
  18.  
  19.             <p data-aura-rendered-by="435:0"><img src="https://www.w3web.net/wp-content/uploads/2021/05/thumbsUpLike.png" width="25" height="25" style="vertical-align:top; margin-right:10px;" data-aura-rendered-by="436:0"><strong data-aura-rendered-by="437:0"><span style="font-size:16px; font-style:italic; display:inline-block; margin-right:5px;">Don't forget to check out:-</span><a href="https://www.w3web.net/" target="_blank" rel="noopener noreferrer" style="text-decoration:none;" data-aura-rendered-by="440:0">An easy way to learn step-by-step online free Salesforce tutorial, To know more Click  <span style="color:#ff8000; font-size:18px;" data-aura-rendered-by="442:0">Here..</span></a></strong></p>
  20.  
  21.             <br/><br/>
  22.             <p data-aura-rendered-by="435:0"><img src="https://www.w3web.net/wp-content/uploads/2021/07/tickMarkIcon.png" width="25" height="25" style="vertical-align:top; margin-right:10px;" data-aura-rendered-by="436:0"><strong data-aura-rendered-by="437:0"><span style="font-size:17px; font-style:italic; display:inline-block; margin-right:5px; color:rgb(255 128 0);">You May Also Like →</span> </strong></p>
  23.             <div style="display:block; overflow:hidden;"> 
  24.                 <div style="width: 50%; float:left; display:inline-block">
  25.                     <ul style="list-style-type: square; font-size: 16px; margin: 0 0 0 54px; padding: 0;"> 
  26.                         <li><a href="https://www.w3web.net/lwc-get-set-lightning-checkbox-value/" target="_blank" rel="noopener noreferrer">How to get selected checkbox value in lwc</a></li>
  27.                         <li><a href="https://www.w3web.net/display-account-related-contacts-in-lwc/" target="_blank" rel="noopener noreferrer">how to display account related contacts based on AccountId in lwc</a></li>
  28.                         <li><a href="https://www.w3web.net/create-lightning-datatable-row-actions-in-lwc/" target="_blank" rel="noopener noreferrer">how to create lightning datatable row actions in lwc</a></li>
  29.                         <li><a href="https://www.w3web.net/if-and-else-condition-in-lwc/" target="_blank" rel="noopener noreferrer">how to use if and else condition in lwc</a></li>
  30.                         <li><a href="https://www.w3web.net/get-selected-radio-button-value-and-checked-default-in-lwc/" target="_blank" rel="noopener noreferrer">how to display selected radio button value in lwc</a></li>
  31.                     </ul>
  32.             </div>
  33.  
  34.             <div style="width: 50%; float:left; display:inline-block">
  35.                     <ul style="list-style-type: square; font-size: 16px; margin: 0 0 0 54px; padding: 0;"> 
  36.                         <li><a href="https://www.w3web.net/display-account-related-contacts-lwc/" target="_blank" rel="noopener noreferrer">display account related contacts based on account name in lwc</a></li>
  37.                         <li><a href="https://www.w3web.net/create-lightning-datatable-row-actions-in-lwc/" target="_blank" rel="noopener noreferrer">how to insert a record of account Using apex class in LWC</a></li>
  38.                         <li><a href="https://www.w3web.net/fetch-picklist-values-dynamic-in-lwc/" target="_blank" rel="noopener noreferrer">how to get picklist values dynamically in lwc</a></li>
  39.                         <li><a href="https://www.w3web.net/edit-save-and-remove-rows-dynamically-in-lightning-component/" target="_blank" rel="noopener noreferrer">how to edit/save row dynamically in lightning component</a></li>
  40.                         <li><a href="https://www.w3web.net/update-parent-object-from-child/" target="_blank" rel="noopener noreferrer">update parent field from child using apex trigger</a></li>
  41.                     </ul>
  42.                 </div>
  43.                <div style="clear:both;"></div> 
  44.                <br/>
  45.                 <div class="youtubeIcon">
  46.                     <a href="https://www.youtube.com/channel/UCW62gTen2zniILj9xE6LmOg" target="_blank" rel="noopener noreferrer"><img src="https://www.w3web.net/wp-content/uploads/2021/11/youtubeIcon.png" width="25" height="25" style="vertical-align:top; margin-right:10px;"/> <strong>TechW3web:-</strong> To know more, Use this <span style="color: #ff8000; font-weight: bold;">Link</span> </a>
  47.                 </div>
  48.     </div>
  49.  
  50. </div>
  51.  
  52.   <!--End RelatedTopics Section-->
  53.  
  54.     </div>
  55. </div> 
  56. </lightning-card>   
  57. </template>

Create Lightning Web Component JavaScript →

Step 2:- Create Lightning Web Component : lwcTreeGrid.js

SFDX:Lightning Web Component >> New >> lwcTreeGrid.js

lwcTreeGrid.js [LWC JavaScript File]

  1.    import { LightningElement, track } from 'lwc';
  2. import {
  3.     EXAMPLES_COLUMNS_DEFINITION_BASIC,
  4.     EXAMPLES_DATA_BASIC,
  5. } from './sampleData';
  6.  
  7. export default class LwcTreeGrid extends LightningElement {
  8.     @track currentExpandedRows;
  9.  
  10.     // definition of columns for the tree grid
  11.     gridColumns = EXAMPLES_COLUMNS_DEFINITION_BASIC;
  12.  
  13.     // data provided to the tree grid
  14.     gridData = EXAMPLES_DATA_BASIC;
  15.  
  16.     // list of names for rows that are expanded
  17.     gridExpandedRows = [
  18.         '123556',
  19.         '123556-A',
  20.         '123556-B',
  21.         '123556-B-B',
  22.         '123557',
  23.     ];
  24.  
  25.     // retrieve the list of rows currently marked as expanded
  26.     getCurrentExpandedRows() {
  27.         const treegrid = this.template.querySelector('.lgc-example-treegrid');
  28.         this.currentExpandedRows = treegrid.getCurrentExpandedRows().toString();
  29.     }
  30.  
  31. }

Create Lightning Web Component JavaScript →

Step 3:- Create Lightning Web Component : sampleData.js

SFDX:Lightning Web Component >> New >> sampleData.js

sampleData.js [LWC JavaScript File]

  1.  
  2.  export const KEYFIELD = 'name';
  3.  
  4.  
  5.  export const COLUMNS_DEFINITION_BASIC = [
  6.      {
  7.          type: 'text',
  8.          fieldName: 'accountName',
  9.          label: 'Account Name',
  10.      },
  11.      {
  12.          type: 'phone',
  13.          fieldName: 'phone',
  14.          label: 'Phone Number',
  15.      },
  16.  ];
  17.  
  18.  
  19.  export const COLUMNS_DEFINITION_NONWHITELIST = [
  20.      {
  21.          type: 'text',
  22.          fieldName: 'accountName',
  23.          label: 'Account Name',
  24.      },
  25.      {
  26.          type: 'phone',
  27.          fieldName: 'phone',
  28.          label: 'Phone Number',
  29.          sortable: true,
  30.      },
  31.  ];
  32.  
  33.  
  34.  export const EXAMPLES_COLUMNS_DEFINITION_BASIC = [
  35.      {
  36.          type: 'text',
  37.          fieldName: 'accountName',
  38.          label: 'Account Name',
  39.          initialWidth: 300,
  40.      },
  41.      {
  42.          type: 'number',
  43.          fieldName: 'employees',
  44.          label: 'Employees',
  45.      },
  46.      {
  47.          type: 'phone',
  48.          fieldName: 'phone',
  49.          label: 'Phone Number',
  50.      },
  51.      {
  52.          type: 'url',
  53.          fieldName: 'accountOwner',
  54.          label: 'Account Owner',
  55.          typeAttributes: {
  56.              label: { fieldName: 'accountOwnerName' },
  57.          },
  58.      },
  59.      {
  60.          type: 'text',
  61.          fieldName: 'billingCity',
  62.          label: 'Billing City',
  63.      },
  64.  ];
  65.  
  66.  
  67.  export const EXPANDED_ROWS_BASIC = ['584996-s7', '377526-zg'];
  68.  
  69.  
  70.  export const EXPANDED_ROWS_MISSING_CHILDREN_CONTENT = [
  71.      '584996-s7',
  72.      '377526-zg',
  73.      '816682-xr',
  74.  ];
  75.  
  76.  
  77.  export const EXPANDED_ROWS_INVALID = [
  78.      '584996-s7',
  79.      '377526-zg',
  80.      'AWEFUL-bad_iD',
  81.      '882894-s3',
  82.      'PiCkLeS',
  83.      '31337-ID',
  84.  ];
  85.  
  86.  
  87.  export const SELECTED_ROWS_BASIC = ['125313-7j', '584996-s7'];
  88.  
  89.  
  90.  export const SELECTED_ROWS_INVALID = [
  91.      '584996-s7',
  92.      '377526-zg',
  93.      'AWEFUL-bad_iD',
  94.      '882894-s3',
  95.      'PiCkLeS',
  96.      '31337-ID',
  97.  ];
  98.  
  99.  
  100.  export const DATA_BASIC = [
  101.      {
  102.          name: '125313-7j',
  103.          accountName: 'Dach-Welch',
  104.          phone: '837-555-0100',
  105.      },
  106.      {
  107.          name: '584996-s7',
  108.          accountName: 'Corkery-Windler',
  109.          phone: '837-555-0100',
  110.          _children: [
  111.              {
  112.                  name: '747773-jw',
  113.                  accountName: 'Corkery-Abshire',
  114.                  phone: '837-555-0100',
  115.              },
  116.              {
  117.                  name: '377526-zg',
  118.                  accountName: 'Robel, Friesen and Flatley',
  119.                  phone: '837-555-0100',
  120.                  _children: [
  121.                      {
  122.                          name: '955330-wp',
  123.                          accountName: 'Donnelly Group',
  124.                          phone: '837-555-0100',
  125.                      },
  126.                      {
  127.                          name: '343693-9x',
  128.                          accountName: 'Kshlerin Group',
  129.                          phone: '837-555-0100',
  130.                      },
  131.                  ],
  132.              },
  133.              {
  134.                  name: '638483-y2',
  135.                  accountName: 'Bruen, Steuber and Spencer',
  136.                  phone: '837-555-0100',
  137.              },
  138.          ],
  139.      },
  140.      {
  141.          name: '306979-mx',
  142.          accountName: 'Spinka LLC',
  143.          phone: '837-555-0100',
  144.      },
  145.      {
  146.          name: '066195-o1',
  147.          accountName: 'Koelpin LLC',
  148.          phone: '837-555-0100',
  149.          _children: [],
  150.      },
  151.  ];
  152.  
  153.  
  154.  export const DATA_MISSING_CHILDREN_CONTENT = [
  155.      {
  156.          name: '125313-7j',
  157.          accountName: 'Dach-Welch',
  158.          phone: '837-555-0100',
  159.      },
  160.      {
  161.          name: '584996-s7',
  162.          accountName: 'Corkery-Windler',
  163.          phone: '837-555-0100',
  164.          _children: [],
  165.      },
  166.      {
  167.          name: '816682-xr',
  168.          accountName: 'Schmitt-Littel',
  169.          phone: '837-555-0100',
  170.          _children: [
  171.              {
  172.                  name: '118985-mf',
  173.                  accountName: 'Hegmann-Turcotte',
  174.                  phone: '837-555-0100',
  175.              },
  176.              {
  177.                  name: '841476-yo',
  178.                  accountName: 'Kuhlman LLC',
  179.                  phone: '837-555-0100',
  180.              },
  181.          ],
  182.      },
  183.      {
  184.          name: '653331-j4',
  185.          accountName: 'Swaniawski-Hilpert',
  186.          phone: '366-145-6134',
  187.          _children: [
  188.              {
  189.                  name: '605249-ei',
  190.                  accountName: 'Swaniawski, Veum and Barton',
  191.                  phone: '837-555-0100',
  192.              },
  193.              {
  194.                  name: '686777-5d',
  195.                  accountName: 'Lubowitz, McClure and Russel',
  196.                  phone: '837-555-0100',
  197.              },
  198.              {
  199.                  name: '582166-n4',
  200.                  accountName: 'Reichel-Jerde',
  201.                  phone: '837-555-0100',
  202.                  _children: [
  203.                      {
  204.                          name: '513683-mm',
  205.                          accountName: 'Tromp Inc',
  206.                          phone: '837-555-0100',
  207.                      },
  208.                  ],
  209.              },
  210.          ],
  211.      },
  212.      {
  213.          name: '306979-mx',
  214.          accountName: 'Spinka LLC',
  215.          phone: '837-555-0100',
  216.      },
  217.      {
  218.          name: '066195-o1',
  219.          accountName: 'Koelpin LLC',
  220.          phone: '837-555-0100',
  221.          _children: [],
  222.      },
  223.  ];
  224.  
  225.  
  226.  export const EXAMPLES_DATA_BASIC = [
  227.      {
  228.          name: '123555',
  229.          accountName: 'Rewis Inc',
  230.          employees: 3100,
  231.          phone: '837-555-0100',
  232.          accountOwner: 'http://salesforce.com/fake/url/jane-doe',
  233.          accountOwnerName: 'Jane Doe',
  234.          billingCity: 'Phoeniz, AZ',
  235.      },
  236.  
  237.      {
  238.          name: '123556',
  239.          accountName: 'Acme Corporation',
  240.          employees: 10000,
  241.          phone: '837-555-0100',
  242.          accountOwner: 'http://salesforce.com/fake/url/jane-doe',
  243.          accountOwnerName: 'John Doe',
  244.          billingCity: 'San Francisco, CA',
  245.          _children: [
  246.              {
  247.                  name: '123556-A',
  248.                  accountName: 'Acme Corporation (Bay Area)',
  249.                  employees: 3000,
  250.                  phone: '837-555-0100',
  251.                  accountOwner: 'http://salesforce.com/fake/url/jane-doe',
  252.                  accountOwnerName: 'John Doe',
  253.                  billingCity: 'New York, NY',
  254.                  _children: [
  255.                      {
  256.                          name: '123556-A-A',
  257.                          accountName: 'Acme Corporation (Oakland)',
  258.                          employees: 745,
  259.                          phone: '837-555-0100',
  260.                          accountOwner: 'http://salesforce.com/fake/url/jane-doe',
  261.                          accountOwnerName: 'John Doe',
  262.                          billingCity: 'New York, NY',
  263.                      },
  264.                      {
  265.                          name: '123556-A-B',
  266.                          accountName: 'Acme Corporation (San Francisco)',
  267.                          employees: 578,
  268.                          phone: '837-555-0100',
  269.                          accountOwner: 'http://salesforce.com/fake/url/jane-doe',
  270.                          accountOwnerName: 'Jane Doe',
  271.                          billingCity: 'Los Angeles, CA',
  272.                      },
  273.                  ],
  274.              },
  275.  
  276.              {
  277.                  name: '123556-B',
  278.                  accountName: 'Acme Corporation (East)',
  279.                  employees: 430,
  280.                  phone: '837-555-0100',
  281.                  accountOwner: 'http://salesforce.com/fake/url/jane-doe',
  282.                  accountOwnerName: 'John Doe',
  283.                  billingCity: 'San Francisco, CA',
  284.                  _children: [
  285.                      {
  286.                          name: '123556-B-A',
  287.                          accountName: 'Acme Corporation (NY)',
  288.                          employees: 1210,
  289.                          phone: '837-555-0100',
  290.                          accountOwner: 'http://salesforce.com/fake/url/jane-doe',
  291.                          accountOwnerName: 'Jane Doe',
  292.                          billingCity: 'New York, NY',
  293.                      },
  294.                      {
  295.                          name: '123556-B-B',
  296.                          accountName: 'Acme Corporation (VA)',
  297.                          employees: 410,
  298.                          phone: '837-555-0100',
  299.                          accountOwner: 'http://salesforce.com/fake/url/jane-doe',
  300.                          accountOwnerName: 'John Doe',
  301.                          billingCity: 'New York, NY',
  302.                          _children: [
  303.                              {
  304.                                  name: '123556-B-B-A',
  305.                                  accountName: 'Allied Technologies',
  306.                                  employees: 390,
  307.                                  phone: '837-555-0100',
  308.                                  accountOwner:
  309.                                      'http://salesforce.com/fake/url/jane-doe',
  310.                                  accountOwnerName: 'Jane Doe',
  311.                                  billingCity: 'Los Angeles, CA',
  312.                                  _children: [
  313.                                      {
  314.                                          name: '123556-B-B-A-A',
  315.                                          accountName: 'Allied Technologies (UV)',
  316.                                          employees: 270,
  317.                                          phone: '837-555-0100',
  318.                                          accountOwner:
  319.                                              'http://salesforce.com/fake/url/jane-doe',
  320.                                          accountOwnerName: 'John Doe',
  321.                                          billingCity: 'San Francisco, CA',
  322.                                      },
  323.                                  ],
  324.                              },
  325.                          ],
  326.                      },
  327.                  ],
  328.              },
  329.          ],
  330.      },
  331.  
  332.      {
  333.          name: '123557',
  334.          accountName: 'Rhode Enterprises',
  335.          employees: 6000,
  336.          phone: '837-555-0100',
  337.          accountOwner: 'http://salesforce.com/fake/url/jane-doe',
  338.          accountOwnerName: 'John Doe',
  339.          billingCity: 'New York, NY',
  340.          _children: [
  341.              {
  342.                  name: '123557-A',
  343.                  accountName: 'Rhode Enterprises (UCA)',
  344.                  employees: 2540,
  345.                  phone: '837-555-0100',
  346.                  accountOwner: 'http://salesforce.com/fake/url/jane-doe',
  347.                  accountOwnerName: 'John Doe',
  348.                  billingCity: 'New York, NY',
  349.              },
  350.          ],
  351.      },
  352.  
  353.      {
  354.          name: '123558',
  355.          accountName: 'Tech Labs',
  356.          employees: 1856,
  357.          phone: '837-555-0100',
  358.          accountOwner: 'http://salesforce.com/fake/url/jane-doe',
  359.          accountOwnerName: 'John Doe',
  360.          billingCity: 'New York, NY',
  361.          _children: [
  362.              {
  363.                  name: '123558-A',
  364.                  accountName: 'Opportunity Resources Inc',
  365.                  employees: 1934,
  366.                  phone: '837-555-0100',
  367.                  accountOwner: 'http://salesforce.com/fake/url/jane-doe',
  368.                  accountOwnerName: 'John Doe',
  369.                  billingCity: 'Los Angeles, CA',
  370.              },
  371.          ],
  372.      },
  373.  ];
  374.  
  375.  
  376.  export const EXAMPLES_DATA_LAZY_LOADING = [
  377.      {
  378.          name: '123555',
  379.          accountName: 'Rewis Inc',
  380.          employees: 3100,
  381.          phone: '837-555-0100',
  382.          accountOwner: 'http://salesforce.com/fake/url/jane-doe',
  383.          accountOwnerName: 'Jane Doe',
  384.          billingCity: 'Phoeniz, AZ',
  385.      },
  386.  
  387.      {
  388.          name: '123556',
  389.          accountName: 'Acme Corporation',
  390.          employees: 10000,
  391.          phone: '837-555-0100',
  392.          accountOwner: 'http://salesforce.com/fake/url/jane-doe',
  393.          accountOwnerName: 'John Doe',
  394.          billingCity: 'San Francisco, CA',
  395.          _children: [
  396.              {
  397.                  name: '123556-A',
  398.                  accountName: 'Acme Corporation (Bay Area)',
  399.                  employees: 3000,
  400.                  phone: '837-555-0100',
  401.                  accountOwner: 'http://salesforce.com/fake/url/jane-doe',
  402.                  accountOwnerName: 'John Doe',
  403.                  billingCity: 'New York, NY',
  404.                  _children: [],
  405.              },
  406.  
  407.              {
  408.                  name: '123556-B',
  409.                  accountName: 'Acme Corporation (East)',
  410.                  employees: 430,
  411.                  phone: '837-555-0100',
  412.                  accountOwner: 'http://salesforce.com/fake/url/jane-doe',
  413.                  accountOwnerName: 'John Doe',
  414.                  billingCity: 'San Francisco, CA',
  415.                  _children: [
  416.                      {
  417.                          name: '123556-B-A',
  418.                          accountName: 'Acme Corporation (NY)',
  419.                          employees: 1210,
  420.                          phone: '837-555-0100',
  421.                          accountOwner: 'http://salesforce.com/fake/url/jane-doe',
  422.                          accountOwnerName: 'Jane Doe',
  423.                          billingCity: 'New York, NY',
  424.                      },
  425.                      {
  426.                          name: '123556-B-B',
  427.                          accountName: 'Acme Corporation (VA)',
  428.                          employees: 410,
  429.                          phone: '837-555-0100',
  430.                          accountOwner: 'http://salesforce.com/fake/url/jane-doe',
  431.                          accountOwnerName: 'John Doe',
  432.                          billingCity: 'New York, NY',
  433.                          _children: [],
  434.                      },
  435.                  ],
  436.              },
  437.          ],
  438.      },
  439.  
  440.      {
  441.          name: '123557',
  442.          accountName: 'Rhode Enterprises',
  443.          employees: 6000,
  444.          phone: '837-555-0100',
  445.          accountOwner: 'http://salesforce.com/fake/url/jane-doe',
  446.          accountOwnerName: 'John Doe',
  447.          billingCity: 'New York, NY',
  448.          _children: [
  449.              {
  450.                  name: '123557-A',
  451.                  accountName: 'Rhode Enterprises (UCA)',
  452.                  employees: 2540,
  453.                  phone: '837-555-0100',
  454.                  accountOwner: 'http://salesforce.com/fake/url/jane-doe',
  455.                  accountOwnerName: 'John Doe',
  456.                  billingCity: 'New York, NY',
  457.              },
  458.          ],
  459.      },
  460.  
  461.      {
  462.          name: '123558',
  463.          accountName: 'Tech Labs',
  464.          employees: 1856,
  465.          phone: '837-555-0100',
  466.          accountOwner: 'http://salesforce.com/fake/url/jane-doe',
  467.          accountOwnerName: 'John Doe',
  468.          billingCity: 'New York, NY',
  469.          _children: [
  470.              {
  471.                  name: '123558-A',
  472.                  accountName: 'Opportunity Resources Inc',
  473.                  employees: 1934,
  474.                  phone: '837-555-0100',
  475.                  accountOwner: 'http://salesforce.com/fake/url/jane-doe',
  476.                  accountOwnerName: 'John Doe',
  477.                  billingCity: 'Los Angeles, CA',
  478.              },
  479.          ],
  480.      },
  481.  ];

Create Component Style CSS →

Step 4:- Create Lightning Web Component : lwcTreeGrid.css

SFDX:Lightning Web Component >> New >> lwcTreeGrid.css

lwcTreeGrid.css [Style CSS]

  1.   .lgc-bg {
  2.     background-color: rgb(242, 242, 242);
  3. }
  4.  
  5. .lgc-bg-inverse {
  6.     background-color: rgb(22, 50, 92);
  7. }

Create Lightning Web Component Meta XML →

Step 5:- Create Lightning Web Component : lwcTreeGrid.js-meta.xml

SFDX:Lightning Web Component >> New >> lwcTreeGrid.js-meta.xml

lwcTreeGrid.js-meta.xml [LWC Meta Data XML]

  1.   <?xml version="1.0" encoding="UTF-8"?>
  2. <LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
  3.     <apiVersion>45.0</apiVersion>
  4.     <isExposed>true</isExposed>
  5.     <targets> 
  6.         <target>lightning__AppPage</target>
  7.         <target>lightning__RecordPage</target>
  8.         <target>lightning__HomePage</target>
  9.     </targets>
  10. </LightningComponentBundle>

 

Further post that would you like to learn in Salesforce

Flyout is a free, simple way to earn money.

If you think you and your family members also like to earn money in additional time, then go this link. In this site, you can earn money for the lifetime at low effort. To Earn Unlimited Everyday With This Trick, Sign Up Free.. Get Started for Free

Flyout is a free, simple way to earn money by placing sponsored content on your blog

Check Out:- Earn Unlimited Everyday With This Trick:- Click Here

 


 

FAQ (Frequently Asked Questions)

What is Lightning Tree grid?

A tree grid displays structured data in a table with expandable rows.

What is not supported in the Lightning Tree grid?

This component inherits styling from trees in the Lightning Design System. Inline editing and sorting of columns are not supported.

How do you make a grid in lightning component?

A) Add a grid container by adding slds-grid to an HTML element. B) Add as many slds-col elements as you want inside of your grid container.

Related Topics | You May Also Like

 
Note:: – You will get an email, so put correct email and mobile number and BEGIN YOUR JOURNEY from Today!
 
 
  

Our Free Courses →

👉 Get Free Course →

📌 Salesforce Administrators

📌 Salesforce Lightning Flow Builder

📌 Salesforce Record Trigger Flow Builder

👉 Get Free Course →

📌 Aura Lightning Framework

📌 Lightning Web Component (LWC)

📌 Rest APIs Integration



Hi, This is Vijay Kumar behind the admin and founder of w3web.net. I am a senior software developer and working in MNC company from more than 8 years. I am great fan of technology, configuration, customization & development. Apart of this, I love to write about Blogging in spare time, Working on Mobile & Web application development, Salesforce lightning, Salesforce LWC and Salesforce Integration development in full time. [Read full bio] | | The Sitemap where you can find all published post on w3web.net

Leave a Comment