How to render dynamic columns in ejGrid after extracting the grid in a reusable component?

Hi Support,

I'm trying to implement a reusable component that encapsulates the ejGrid component. My problem lies within the part concerning whether the column has a template or not. 


For context, I implemented a DyncamicGridComponent that encapsulates the grid. Then, from a parent component, I pass to the dynamicGridComponent my columns config through property binding.

kindly review the attached relevant files for more insights regarding my code.


Attachment: SyncfusionAttachments_3c79df12.rar

2 Replies

OM Omar June 7, 2023 10:01 AM UTC

Here's a demo app of the issue


Attachment: DemoApp_970b963d.rar


DM Dineshnarasimman Muthu Syncfusion Team June 16, 2023 04:57 AM UTC

Hi Omar,


We have reviewed your query about issue in rendering component in column template. We have validated the sample and noticed that you have used different field names in the grid columns and when initializing the data. We have set the same field names and declared the column template in the ngAfterViewInit() by accessing the gridColumns. We have attached code snippet and sample for your reference.


ngOnInit()

this.projects = [

      { id: 1, name: 'ABC', creation_time: new Date(), description: 'desc1' },

    ];

 


ngAfterViewInit()

ngAfterViewInit(): void {

    //Called after ngAfterContentInit when the component's view has been initialized.       Applies to components only.

    //Add 'implements AfterViewInit' to the class.

   this.gridColumns[2].template=this.creationTimeTemplate

   this.gridColumns[2].templateFn=templateCompiler(this.creationTimeTemplate as any)

  }

 


Please let us know if you need any further assistance.


Regards,

Dineshnarasimman


Attachment: CustomSample_5eebdc07.zip

Loader.
Up arrow icon