PDA

View Full Version : Dynamic number of columns of table component



beldario
08-07-2012, 04:13 AM
Hello, after getting to a dynamic query with spoon I have encountered the following problem in CDE.

The query I do not have a fixed number of columns. When first execution the table component draws well, and if I run the query with a result with the same number of columns as well do it right, but if, according to a filter that I have, the number of columns is different I get the following error "DataTables warning (table id = 'datosTable'): Added data (size 5) does not match known number of columns (4)".

I need help urgently please have someone help me.
Some form of redrawing the table component, or remove it and repaint it, somehow ...

hansva
08-07-2012, 05:51 AM
You will have to use the post fetch function to check the amount of columns the datasource pulls.
not really sure what you have to change to the table to make it stop complaining (i'm guessing chartDefinition will be enough)

beldario
08-07-2012, 06:26 AM
I see the number of columns of resultset with this.queryState.lastResults().resultset, and the number of current columns of the table component with this.chartDefinition.colHeaders.length, but i cant change the number of columns. In chartDefinition i cant see a properti for do that.

Any idea?

lukolap
08-07-2012, 06:48 AM
Hi,
I'm going to use an example to show you the solution I use in this cases... probably it's not the best solution but it's work...
If my query returns from 5 to 10 columns, I set 10 fixed columns in my dataTable.
When the number of columns returned by the query is less than 10, I hide (using css properties) the table columns I don't need.
I do that in the draw function.

beldario
08-07-2012, 07:07 AM
Sorry, your solution may be valid, but i dont like me. I will consider it if i havent other choose. But what i want is something more easy.
I have other chart, a line chart, this chart is redraw when the listener active it, and the new columns are added without problems. My question is why in table component dont happens that. What i want is if there is a function to redraw or reset the table component in preexecution or in pre change, for what each execution will be as the first

(sorry for my english xD)

beldario
08-08-2012, 06:35 AM
Im trying with something like Dashboards.components[i].clear(), Dashboards.update(components[i]), Dashboards.init(component), Dashboards.initEngine(component), Dashboards.RefreshEngine()...
but nothing works...
Someone can help me?

nevets525
06-20-2013, 10:50 AM
hey. try this function in the 'pre execution' of the table component. it worked for me;


function() {
this.chartDefinition.colHeaders = [];
this.chartDefinition.colTypes = [];
this.chartDefinition.colFormats = [];
}


S

juliano.segoa@gmail.com
11-12-2013, 08:19 AM
it's work me too!

thanks

Meherun
07-23-2015, 02:46 AM
Great solution for dynamic column header problem



hey. try this function in the 'pre execution' of the table component. it worked for me;


function() {
this.chartDefinition.colHeaders = [];
this.chartDefinition.colTypes = [];
this.chartDefinition.colFormats = [];
}


S

jaapandre
02-02-2016, 03:38 AM
Great solution, however with no data, it returns an "Error processing component", caused by this.chartDefinition.colHeaders=[]. So I think a check if data is available should be added, but how to perform?

Groets,

Jaap-Andre