Update no record template dynamically in hierarchical grid

Hello
i want a working solution of updating dynamically no record template of a child grid


3 Replies

SI Santhosh Iruthayaraj Syncfusion Team April 4, 2025 11:03 AM UTC

Hi Garima Jain,


Greetings from Syncfusion Support.


As per your request, we have created a sample that demonstrates how to dynamically set the “emptyRecordTemplate” for child Grids. This functionality is achieved using the “detailDataBound” event of the parent Grid, which is triggered each time a child Grid is rendered. Please refer to the following code snippet and sample link:


[index.js]

 

  const detailDataBound = (args=> {

    const emptyRecordTemplate = `

        <div className='emptyRecordTemplate' style="text-align: center;">

            <span>No orders placed by Employee <b>${args.data.FirstName}</b></span>

        </div>

    `;

    args.childGrid.emptyRecordTemplate = emptyRecordTemplate;

  };

 

  return (

    <div className="control-pane">

      <div className="control-section">

        <GridComponent

          ref={(g=> (grid = g)}

          dataSource={employeeData}

          childGrid={childGrid}

          allowSorting={true}

          allowFiltering={true}

          filterSettings={filterSettings}

          detailDataBound={detailDataBound}

          dataBound={dataBound}

        >

         .  .  .  .  .

 


Sample: https://stackblitz.com/edit/react-pjbs1ctg-phrazdu7


In this sample, the emptyRecordTemplate is dynamically configured to display the respective employee’s first name with the empty record message.


We hope this solution meets your requirement. Please let us know if you need any further assistance.


Regards,

Santhosh I



GJ Garima Jain April 9, 2025 01:56 PM UTC

Hello  i have attached my code & this is not working for child grid


Image_7338_1744206988118


Attachment: child_grid_b661f1c3.txt


SI Santhosh Iruthayaraj Syncfusion Team April 16, 2025 10:33 AM UTC

Hi Garima Jain,


We have created a sample that closely aligns with the code structure you provided and have tested the dynamic empty row setup. Based on our validation, the behavior is working as expected. For your reference, please find the sample and a vide demonstration attached below:


Sample: https://stackblitz.com/edit/react-pjbs1ctg-y6kbsy3z


However, we understand that the reported issue occurs on your end. Since we are unable to reproduce the issue on our end, we kindly request you to either reproduce the issue using the provided sample within your application context or share a runnable sample that replicates the problem. This will allow us to validate the scenario more accurately and provide a targeted resolution.


Regards,

Santhosh I


Attachment: dynamicemptyrecordtemplate.mp4_902d76ac.zip

Loader.
Up arrow icon