Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
220
Igx-grid - Accessing Headers on dynamically generated columns
posted

Hi,

I am having an issue when trying to access the Header property of dynamically generated columns on an igx-grid.

When creating the following grid with an ngFor for the columns:

Using this data:

I get the following grid, which is exactly what I want (row data is unimportant for this demo):

However, I want to be able to use the column's header to perform some functionality when I select a cell.  I use the following function to display the column object:

But when selecting anything from any column (in this example, the first cell in the 'column 2'), the console returns the following:

Investigating further, just receiving the column returns the column object and, right enough, the header is incorrect:

It seems that in dynamically generated columns, even though the headers are visibly set, selecting the cell does not return the correct column header, instead defaulting to the first one.

Can you propose a solution to this problem?

Thanks!

Adam Drew

Parents
No Data
Reply
  • 1560
    Verified Answer
    Offline posted

    Hello,

    I have been looking into your question and prepared a small sample in order to test the behavior.

    After an investigation, I have determined that the issue is because the columns' fields are not set.

    The header property of the columns is the text displayed in their header area, however, setting the field is actually binding the column to a certain field in the data source.

    After the field of the column is set properly, everything seems to work as expected on my side and the correct header value is returned.

    Here could be found my sample for your reference. Please test it on your side and let me know if I may be of any further assistance.


    Sincerely,
    Teodosia Hristodorova
    Software Developer

Children