<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Ravi surani</title>
    <description>The latest articles on DEV Community by Ravi surani (@ravi_surani).</description>
    <link>https://dev.to/ravi_surani</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F2503105%2F5bcf5024-0482-4235-949d-9b2c0641744a.png</url>
      <title>DEV Community: Ravi surani</title>
      <link>https://dev.to/ravi_surani</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ravi_surani"/>
    <language>en</language>
    <item>
      <title>Understanding AG Grid Tree Data Mode in React</title>
      <dc:creator>Ravi surani</dc:creator>
      <pubDate>Sun, 23 Mar 2025 09:10:13 +0000</pubDate>
      <link>https://dev.to/ravi_surani/understanding-ag-grid-tree-data-mode-in-react-32ga</link>
      <guid>https://dev.to/ravi_surani/understanding-ag-grid-tree-data-mode-in-react-32ga</guid>
      <description>&lt;p&gt;AG Grid is a powerful React data table library that provides various features, including &lt;strong&gt;Tree Data mode&lt;/strong&gt; for hierarchical data visualization. Tree Data mode allows users to display &lt;strong&gt;parent-child relationships&lt;/strong&gt; in a structured grid.  &lt;/p&gt;

&lt;p&gt;In this blog, we will explore:&lt;br&gt;&lt;br&gt;
✅ What is Tree Data Mode?&lt;br&gt;&lt;br&gt;
✅ Important parameters and their values&lt;br&gt;&lt;br&gt;
✅ An implementation example  &lt;/p&gt;


&lt;h2&gt;
  
  
  &lt;strong&gt;What is Tree Data Mode?&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Tree Data mode enables AG Grid to display hierarchical data in a &lt;strong&gt;grid format&lt;/strong&gt;, where some rows act as &lt;strong&gt;parents&lt;/strong&gt; containing &lt;strong&gt;child rows&lt;/strong&gt;.  &lt;/p&gt;

&lt;p&gt;Unlike the built-in &lt;strong&gt;row grouping feature&lt;/strong&gt;, Tree Data mode is useful when data already has a structured hierarchy, such as:  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A &lt;strong&gt;file system&lt;/strong&gt; (folders containing files)
&lt;/li&gt;
&lt;li&gt;An &lt;strong&gt;organizational chart&lt;/strong&gt; (departments with employees)
&lt;/li&gt;
&lt;/ul&gt;


&lt;h2&gt;
  
  
  &lt;strong&gt;Key Parameters in Tree Data Mode&lt;/strong&gt;
&lt;/h2&gt;
&lt;h3&gt;
  
  
  &lt;strong&gt;1️⃣ &lt;code&gt;treeData&lt;/code&gt;&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Type:&lt;/strong&gt; &lt;code&gt;boolean&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Default:&lt;/strong&gt; &lt;code&gt;false&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Description:&lt;/strong&gt; Enables tree data mode in AG Grid.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Usage:&lt;/strong&gt; Set to &lt;code&gt;true&lt;/code&gt; to activate hierarchical data rendering.
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;gridOptions&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;treeData&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  &lt;strong&gt;2️⃣ &lt;code&gt;getDataPath&lt;/code&gt;&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Type:&lt;/strong&gt; &lt;code&gt;function&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Description:&lt;/strong&gt; Defines how AG Grid determines the hierarchy of the dataset by specifying the path of each row.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Usage:&lt;/strong&gt; Returns an array representing the &lt;strong&gt;hierarchical path&lt;/strong&gt; of a row.
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;getDataPath&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;hierarchy&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h4&gt;
  
  
  Example Data:
&lt;/h4&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"hierarchy"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"Electronics"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Laptops"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"MacBook Pro"&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"hierarchy"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"Electronics"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Phones"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"iPhone 13"&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  &lt;strong&gt;3️⃣ &lt;code&gt;autoGroupColumnDef&lt;/code&gt;&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Type:&lt;/strong&gt; &lt;code&gt;object&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Description:&lt;/strong&gt; Configures the column used for displaying hierarchical data.
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;autoGroupColumnDef&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;headerName&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Category&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;cellRendererParams&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;suppressCount&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;// Hides child count next to group name&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  &lt;strong&gt;4️⃣ &lt;code&gt;groupDefaultExpanded&lt;/code&gt;&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Type:&lt;/strong&gt; &lt;code&gt;number&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Default:&lt;/strong&gt; &lt;code&gt;0&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Description:&lt;/strong&gt; Determines how many levels should be expanded by default.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Usage:&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;0&lt;/code&gt; → Collapsed
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;1&lt;/code&gt; → Expand first level
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;-1&lt;/code&gt; → Expand all levels
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;gridOptions&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;groupDefaultExpanded&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  &lt;strong&gt;5️⃣ &lt;code&gt;columnDefs&lt;/code&gt;&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Type:&lt;/strong&gt; &lt;code&gt;array&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Description:&lt;/strong&gt; Defines the columns in the grid.
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;columnDefs&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;field&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;name&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
&lt;span class="p"&gt;];&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  &lt;strong&gt;Example Implementation in React&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Here’s a &lt;strong&gt;full React example&lt;/strong&gt; using AG Grid’s Tree Data mode:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;useState&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;react&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;AgGridReact&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;ag-grid-react&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;ag-grid-community/styles/ag-grid.css&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;ag-grid-community/styles/ag-theme-alpine.css&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;TreeDataExample&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;rowData&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useState&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;hierarchy&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Electronics&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Laptops&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;MacBook Pro&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;hierarchy&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Electronics&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Phones&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;iPhone 13&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;]);&lt;/span&gt;

  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;columnDefs&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[{&lt;/span&gt; &lt;span class="na"&gt;field&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;name&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;}];&lt;/span&gt;

  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;gridOptions&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;treeData&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;getDataPath&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;hierarchy&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;autoGroupColumnDef&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="na"&gt;headerName&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Category&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;cellRendererParams&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;suppressCount&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="na"&gt;groupDefaultExpanded&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;};&lt;/span&gt;

  &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt; &lt;span class="na"&gt;className&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"ag-theme-alpine"&lt;/span&gt; &lt;span class="na"&gt;style&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;500&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;600&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;AgGridReact&lt;/span&gt; &lt;span class="na"&gt;rowData&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;rowData&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt; &lt;span class="na"&gt;columnDefs&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;columnDefs&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt; &lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="p"&gt;...&lt;/span&gt;&lt;span class="nx"&gt;gridOptions&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt; &lt;span class="p"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nx"&gt;TreeDataExample&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  &lt;strong&gt;Conclusion&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;AG Grid’s &lt;strong&gt;Tree Data mode&lt;/strong&gt; provides an efficient way to display &lt;strong&gt;hierarchical data&lt;/strong&gt; in React applications.  &lt;/p&gt;

&lt;p&gt;By configuring parameters like:&lt;br&gt;&lt;br&gt;
✅ &lt;code&gt;treeData&lt;/code&gt; → Enables hierarchy&lt;br&gt;&lt;br&gt;
✅ &lt;code&gt;getDataPath&lt;/code&gt; → Defines data structure&lt;br&gt;&lt;br&gt;
✅ &lt;code&gt;autoGroupColumnDef&lt;/code&gt; → Configures group column&lt;br&gt;&lt;br&gt;
✅ &lt;code&gt;groupDefaultExpanded&lt;/code&gt; → Controls row expansion  &lt;/p&gt;

&lt;p&gt;You can &lt;strong&gt;easily create structured and dynamic tables&lt;/strong&gt;. Try it in your &lt;strong&gt;React project&lt;/strong&gt; and enhance your data presentation! 🚀  &lt;/p&gt;




&lt;h3&gt;
  
  
  🔗 &lt;strong&gt;Want to Learn More?&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;📖 Check out the official &lt;strong&gt;AG Grid Docs&lt;/strong&gt;: &lt;a href="https://www.ag-grid.com/react-data-grid/tree-data/" rel="noopener noreferrer"&gt;https://www.ag-grid.com/react-data-grid/tree-data/&lt;/a&gt;  &lt;/p&gt;

</description>
    </item>
    <item>
      <title>Setting Up Multiple Environments in React.js</title>
      <dc:creator>Ravi surani</dc:creator>
      <pubDate>Sun, 16 Feb 2025 11:19:28 +0000</pubDate>
      <link>https://dev.to/ravi_surani/setting-up-multiple-environments-in-reactjs-24nn</link>
      <guid>https://dev.to/ravi_surani/setting-up-multiple-environments-in-reactjs-24nn</guid>
      <description>&lt;p&gt;When working on a React project, you may need different setups for development, testing, and production. Each environment may require unique API links, features, or settings. Here’s how to set up multiple environments in a simple way.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why Use Different Environments?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Testing: Ensure new features work before going live.&lt;/li&gt;
&lt;li&gt;Security: Keep production data safe.&lt;/li&gt;
&lt;li&gt;Performance: Identify issues in different setups.&lt;/li&gt;
&lt;li&gt;Smooth Deployment: Update without breaking the live site.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;*&lt;em&gt;Steps to Set Up Multiple Environments&lt;br&gt;
*&lt;/em&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Create Environment Files&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;React allows you to use .env files for different setups:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;.env (default)&lt;/li&gt;
&lt;li&gt;.env.development&lt;/li&gt;
&lt;li&gt;.env.staging&lt;/li&gt;
&lt;li&gt;.env.production&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;Define Variables
In each .env file, add variables prefixed with REACT_APP_:
&lt;strong&gt;Example&lt;/strong&gt; .env.development:
&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;REACT_APP_API_URL=https://dev-api.example.com
REACT_APP_FEATURE=true
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;In each .env file, add variables prefixed with REACT_APP_:&lt;br&gt;
&lt;strong&gt;Example&lt;/strong&gt; .env.staging:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;REACT_APP_API_URL=https://staging-api.example.com
REACT_APP_FEATURE=true
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Example&lt;/strong&gt; .env.production:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;REACT_APP_API_URL=https://api.example.com
REACT_APP_FEATURE=false
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Use Variables in Code
Access them in your React app like this:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const apiUrl = process.env.REACT_APP_API_URL;
const featureEnabled = process.env.REACT_APP_FEATURE === "true";

console.log("API URL:", apiUrl);
console.log("Feature Enabled:", featureEnabled);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Set Up Environment-Based Commands
Update package.json to specify environments:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"scripts": {
  "start": "react-scripts start",
  "start:development": "env-cmd -f .env.development npm-run-all -p start-js",
  "start:staging": "env-cmd -f .env.staging npm-run-all -p start-js",
  "start:.production": "env-cmd -f .env.production npm-run-all -p start-js",  
  "build:development": "env-cmd -f .env.development react-scripts build",
  "build:staging": "env-cmd -f .env.staging react-scripts build",
  "build:.production": "env-cmd -f .env.production react-scripts build",
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Using &lt;code&gt;env-cmd&lt;/code&gt; lets you load specific .env files.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Add Environment Variables in Deployment
For hosting services like &lt;strong&gt;Netlify&lt;/strong&gt;, &lt;strong&gt;Vercel&lt;/strong&gt;, or &lt;strong&gt;AWS Amplify&lt;/strong&gt;, set environment variables in their settings. If using &lt;strong&gt;Docker or Kubernetes&lt;/strong&gt;, pass them through configuration files.&lt;/li&gt;
&lt;li&gt;Debugging Environment Variables
To check if variables are loaded, run:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;echo $REACT_APP_API_URL
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Or log them in your app:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;console.log(process.env);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;br&gt;
Using multiple environments in React makes development easier and safer. By setting up .env files and using specific scripts, you can seamlessly switch between different setups.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Why JSON is Super Important for JavaScript (Beginner Friendly!)</title>
      <dc:creator>Ravi surani</dc:creator>
      <pubDate>Sat, 30 Nov 2024 08:19:13 +0000</pubDate>
      <link>https://dev.to/ravi_surani/why-json-is-super-important-for-javascript-beginner-friendly-4d94</link>
      <guid>https://dev.to/ravi_surani/why-json-is-super-important-for-javascript-beginner-friendly-4d94</guid>
      <description>&lt;p&gt;So, you're learning JavaScript, and you've probably stumbled upon this weird-looking thing called JSON. Don't worry, it's not as scary as it looks! In fact, understanding JSON is crucial for building almost any kind of dynamic web application. Let's break down why.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is JSON?
&lt;/h2&gt;

&lt;p&gt;JSON stands for &lt;strong&gt;JavaScript Object Notation&lt;/strong&gt;. Think of it as a simple way to store and exchange data. It's like a universal language that JavaScript (and many other programming languages) can easily understand. Instead of using complex XML files, JSON uses a much simpler, human-readable format.&lt;/p&gt;

&lt;h2&gt;
  
  
  How does it look?
&lt;/h2&gt;

&lt;p&gt;JSON data looks like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  "name": "Alice",
  "age": 30,
  "city": "New York"
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;See? It's just key-value pairs enclosed in curly braces {}. The keys are strings (in quotes), and the values can be strings, numbers, booleans (true/false), or even other JSON objects or arrays. For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  "name": "Bob",
  "age": 25,
  "address": {
    "street": "123 Main St",
    "city": "Los Angeles"
  },
  "hobbies": ["coding", "hiking", "reading"]
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Why is it important for JavaScript?
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Talking to Servers:&lt;/strong&gt; Most web applications need to communicate with servers to fetch or send data. JSON is the most common way to do this. Imagine you're building a to-do list app. Your JavaScript code needs to send requests to a server to save new tasks and retrieve existing ones. The server sends this data back to your JavaScript code in JSON format.&lt;br&gt;
&lt;strong&gt;Storing Data:&lt;/strong&gt; JSON is also great for storing data locally within your web application (using things like localStorage). This lets your app remember user preferences or other important information even when the user closes the browser.&lt;br&gt;
&lt;strong&gt;Easy to Parse:&lt;/strong&gt; JavaScript has built-in functions (JSON.parse()) to easily convert JSON strings into JavaScript objects. This makes it incredibly simple to work with the data received from a server or stored locally. And JSON.stringify() does the opposite, converting a JavaScript object back into a JSON string for sending to a server.&lt;/p&gt;
&lt;h2&gt;
  
  
  Simple Example:
&lt;/h2&gt;

&lt;p&gt;Let's say you receive this JSON from a server:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let jsonData = `{"name":"Charlie","age":28}`;

// Parse the JSON string into a JavaScript object:
let user = JSON.parse(jsonData);

// Now you can access the data:
console.log(user.name); // Outputs "Charlie"
console.log(user.age);  // Outputs 28
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  In a Nutshell:
&lt;/h2&gt;

&lt;p&gt;JSON is a lightweight, easy-to-use data format that acts as a bridge between your JavaScript code and the rest of the world (servers, databases, other applications). Mastering JSON is a fundamental step in becoming a proficient JavaScript developer. Don't be intimidated; with a little practice, you'll be a JSON ninja in no time!&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
