Discussion Closed This discussion was created more than 6 months ago and has been closed. To start a new discussion with a link back to this one, click here.

TableFeature addColumn does not modify Table

Please login with a confirmed email address before reporting spam

Hi,

I am trying to create a Result Table in the App Builder using this code:

String tableTag = model.result().table().uniquetag("dott");
TableFeature table = model.result().table().create(tableTag, "Table");

Later, when I got the results I try to add them column by column using this method:

table.addColumns(new String[]{"time"}, extraArray);
table.addColumns(new String[]{""+thickness}, realdata);

Both extraArray and realdata are double[][] according to the reference. But when I display the Table in a resultstable view, the Table is empty (also when I try to get the data with e.g getColumnHeaders the added Columns do not show up)

Is there any reason for this. Where did I make a mistake?


1 Reply Last Post 3 févr. 2020, 11:49 UTC−5
Lars Dammann COMSOL Employee

Please login with a confirmed email address before reporting spam

Posted: 5 years ago 3 févr. 2020, 11:49 UTC−5
Updated: 5 years ago 3 févr. 2020, 11:49 UTC−5

Hi Daniel, looks to me like adding a new column only works if there is already some data in the table. Try this code:

String tableTag = model.result().table().uniquetag("dott");
TableFeature table = model.result().table().create(tableTag, "Table");

String header = "title";
double[] data = {1.0, 2.0, 3.0};

table.setTableData(transpose(new double[][]{data}));
table.setColumnHeaders(new String[]{header});

table.addColumns(new String[]{header}, transpose(new double[][]{data}));

Best wishes, Lars

Hi Daniel, looks to me like adding a new column only works if there is already some data in the table. Try this code: String tableTag = model.result().table().uniquetag("dott"); TableFeature table = model.result().table().create(tableTag, "Table"); String header = "title"; double[] data = {1.0, 2.0, 3.0}; table.setTableData(transpose(new double[][]{data})); table.setColumnHeaders(new String[]{header}); table.addColumns(new String[]{header}, transpose(new double[][]{data})); Best wishes, Lars

Note that while COMSOL employees may participate in the discussion forum, COMSOL® software users who are on-subscription should submit their questions via the Support Center for a more comprehensive response from the Technical Support team.