cancel
Showing results for 
Search instead for 
Did you mean: 

Table shows content, but says it has no columns

Former Member
0 Kudos

Hello everyone,

In my wdDoModifyView() method, I have the following code:


if (firstTime) {
    wdThis.wdGetContactenController().getContacten();
    int size = tHistorisch.numberOfColumns();
    wdThis.wdGetAPI().getComponent().getMessageManager().reportSuccess("Cols = '"+size+"'");
}

In this, tHistorisch is an IWDTable. The data is retrieved in the controller's getContacten() method, which as you can see, is called. When run, it shows content (28 rows worth, in fact) so the DataSource is valid, and the table has the 10 columns that I gave it when I used Apply Template. Yet, the output of the above code is:

Cols = '0'

Can anyone shed any light on this? Thanks in advance.

Regards,

Kars Meyboom.

Edited by: Kars Meyboom on Jun 5, 2009 10:25 AM

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Probably this is a new table that uses the "GroupedColumns" aggregation and not the deprecated "Columns" aggregation. Change your code to print numberOfGroupedColumns().

Armin

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

Did you create the table dynamically or at design time?

Try this code:

IWDTableColumn[] tableColumns=table.getColumns();
wdThis.wdGetAPI().getComponent().getMessageManager().reportSuccess("size "+tableColumns.length);

Regards,

Charan

Former Member
0 Kudos

Hi Charan,

I tried your code, but still no luck; it reported "size 0". I created the table at design time, not runtime. Thanks for the help though, it's appreciated.

Regards,

Kars.

Former Member
0 Kudos

Okay, I tried the snippet of code on completely different table in a completely different WebDynpro component (adapting it, obviously, for the table in question). This time I did get the right number of colums returned.

Both tables were created at design time, I've gone through their property list to see if there was anything radically different but there wasn't. Did my NWDS screw up somewhere? I've found that the WebDynpro code generator isn't the most reliable piece of the NWDS puzzle...

Former Member
0 Kudos

Hi,

Can you explain what is the reason you are trying to get the no Of Columns. Is this because you are not able to see these columns at design time/ runtime (Or) Is this becuase are you not able to see the data at runtime in the table for all the columns? What is the exact issue?

Regards,

Charan

Former Member
0 Kudos

I can see everything just fine; in the browser the table shows up perfectly, showing the expected data.

The exact issue is that I'm trying to use TableSorter to allow users to sort the table. But the thing isn't working. Meaning the column headings don't become clickable like they're supposed to.

I've been looking at the code for TableSorter, and decided to do some runtime inspection, hence my reason for looking at the numberOfColumns() method. And I think that explains TableSorter's behaviour; since it doesn't find any columns, it can't very well make them sortable, now can it?

I've used the exact same strategy about two years ago on a completely different table in a different WebDynpro DC, and it works just fine there. Right now I'm hacking together a local DC to check if the problem occurs there, too.

Regards,

Kars.

Former Member
0 Kudos

Okay, just to be thorough, here's what I did:

- Created a local WebDynpro DC TableTest_WDP

- Added a TableTestComp and TableTestView

- Defined a "Contacts" value node on the view's context with four attributes LastName, FirstName, Email and Phone

- used Apply Template on the root element in the view to generate a four-column table for the Contacts

- Added the following code in the doModifyView() method:

IWDTable table = (IWDTable) view.getElement("Table");
    wdThis.wdGetAPI().getComponent().getMessageManager().reportSuccess("num cols = "+table.numberOfColumns());

- Created a TableTest_App application

- Built the DC, and used Deploy New Archive and Run

That gave me an empty table, and the message "num cols = 0"

(see the screenshot at [http://analyser.oli.tudelft.nl/sdn/TableTest.jpg] )

Edited by: Kars Meyboom on Jun 5, 2009 11:55 AM

Former Member
0 Kudos

Hi,

If you create table using Template by default it creates grouped columns Not normal colums. So you have to get the size of grouped columns.

In NW2004S

IWDTable table = (IWDTable) view.getElement("Table");
IWDAbstractTableColumn[] tableColumns=table.getGroupedColumns();
wdThis.wdGetAPI().getComponent().getMessageManager().reportSuccess("size "+tableColumns.length);

Regards,

Charan

Former Member
0 Kudos

Thanks everyone, that seems to be it. I'll create the table by hand and use the old IWDTableColumn construction instead. That way the TableSorter will most likely work.

Again, thanks!

Kars.

Former Member
0 Kudos

It's not about using IWDTableColumn, it's about using the "GroupedColumns" aggregation instead of the "Columns" aggregation.

Armin