Table Customizers Not Working After Adding Initializer "table.getColumnModel()"

Hi all.

I have a puzzling problem as I use this format in 4 other tables in my project and it works for all of them except this one. I set up my power tables with header and footer rows by adding them as separate power tables and setting the "table.getColumnModel()" of these header and footer power tables to the table they're associated with. It looks like this:

# Header power table initialize() extension function
myTable = self.parent.getComponent("myTable")
self.table.setColumnModel(myTable.table.getColumnModel())

The main power table "myTable" is populated by a SQL query. It returns a column with the header "ColumnHeader", and I set the "Header" property in table customizers to _HTML_CENTER_Column_BR_Header. When the initialize script of the header power table is disabled and I reload the page, the header of the column is _HTML_CENTER_Column_BR_Header as exepcted. When I have the initialize function enabled, the column header is "ColumnHeader" (what the SQL query returns, and not the formatted header I put in the table customizers).

The initializer script is something I found online, I don't technically understand why it would have this interaction so it's hard for me to debug. If I can supply more details please let me know, but from my own investigation it seems to be linked to just the initialize extension function.

This is an interesting design approach. You're saying that you are essentially using an entire power table for the header, an entire power table for the body, and a third entire power table for the footer? With regard to the header, what advantage does this give for customization over the configureHeaderStyle extension function, or with regard to naming columns, since you are using a query, what advantage does this approach have over SQL aliasing?

Hi Justin. Thank you for replying!

I should clarify, the “header” table is not used as column headers for the table below, it is a single-row table whose fields are editable. Users enter keywords in these columns to filter the data returned in the table below. The “footer” tables are used when I need to show a column summation. I set these tables’ column attributes equal so that if users re-size the columns the column width is sync’d between each table. It gives the illusion of there being just a single table there instead of 3.

That makes sense.

I'm not sure what's goofed up with it, but have you tried deleting it and recreating it from scratch in the designer?

1 Like

Hi Justin.

I'm in the process of re-creating it from scratch and am nearly finished. So far everything is good. But I noticed when I was re-sizing a column named "Size" it was behaving oddly. Columns were re-sizing subsequently even though I had "last column" selected for the auto-resize mode property on both tables. The other columns (there were 10 of them) did not have this issue. Interestingly, "Size" is a keyword property for a power table, so perhaps if people come across this issue in the future they could check whether any of their columns use names of table properties (size, data, name, etc...).

When I encountered the problem originally, I had first re-sized my main table columns how I wanted them before I set the initialize function on the "header" table. While reconstructing it however I initialized the header table to use the column model of the main table before I re-sized anything. Perhaps in the original method when I reloaded the page and it tried to set all of the column widths to be equal it encountered the same issue I did re-sizing the "Size" column and that caused the issue.

I'll leave it for anyone interested to de-bug, I'm satisfied that the issue was resolved just by recreating my tables from scratch.

1 Like

I just re-created what was probably the issue. My main table and header table have to have the same number of columns or the initialize function breaks. I was hiding a column in the table customizer of my main table but not my header table. When I noticed this and hid the column in my header table as well I lost all my main table formatting because I still had the initialize function on the header table enabled. When I closed the page without saving, re-opened it, un-initialized the header table, hid the column, re-initialized it, and re-loaded the page, the main table retained all the formatting it had before.

1 Like