cancel
Showing results for 
Search instead for 
Did you mean: 

How to add the Row count(number of rows in table) in the table header?

Former Member
0 Kudos

Hi,

I'm having a table. This table is viewed when i click on a search button.

<b>On the table header it should dynamically display the number of rows in the table, i.e., the row count.</b>

How to do this? could any one explain me with the detailed procedure to achieve this.

Thanks & Regards,

Suresh

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

If you want to show a localized text in the table header, you should use the <b>Message Pool</b> to create a (parameterized) message "tableHeaderText" like "There are table entries".

Next, create a context attribute "tableHeaderText" of type "string" and bind the "text" property of the table header Caption UI element to this attribute.

Whenever the table data has changed (e.g. at the end of the supply function for the table's data source node), update the header text:

int numRows = wdContext.node<TableDataSourceNode>().size();
String text = wdComponentAPI.getTextAccessor().getText
(
  IMessage<ComponentName>.TABLE_HEADER_TEXT,
  new Object[] { String.valueOf(numRows) }
);
wdContext.currentContextElement().setTableHeaderText(text);

Maybe you want to provide a separate message for the case that there are no entries.

Alternatively, you can make the attribute calculated and return the header text in the attribute getter.

Armin

Former Member
0 Kudos

Armin,

My problem is that, in the header i need to have the table name in the left side and that row count in right side. how to display these both things(table name & row count)in the table header.

in the header it has only one caption ui element. how to do this?

Thanks & Regards,

Suresh

Former Member
0 Kudos

That's not possible with a single caption. Alternatively, you can (if it's worth it)

- make the table header invisible

- create a TransparentContainer around the table

- place two TextViews in the first row

- place the Table in the second row

Then you can set the MatrixData of the two text views such that the first one is left-aligned and the second one (showing the row count) is right-aligned.

The rest is as sketched in my previous post.

Armin

Former Member
0 Kudos

Hi,

In addition to what Armin has said, here's one more way to do it:

1. Create a ToolBar for the table.

2. Insert a ToolBarItem. Select LinkToURL. Set the "<i>design</i>" property to "<i>emphasized</i>", "<i>enabled</i>" property to "<i>false</i>", "<i>reference</i>" property to "<i>#</i>". Bind the "<i>text</i>" property to the context attribute that populates the table header text.

3. Insert a ToolBarRightItem in the ToolBar. Select LinkToURL again. Set the properties as above. Bind the "<i>text</i>" property to the context attribute that populates the table node size.

Regards,

Satyajit.

Former Member
0 Kudos

I would consider this as a misuse of LinkToURL. And what if he later wants to really add some toolbar items?

Armin

Former Member
0 Kudos

Hi,

if you want to get the number of rows

Check the size of the node bound to the table.

Ex:

wdContext.node<YourNode>().size();

To implement this

Create a calculated attribute

in the getter return the size

bind this to the text property of the table header

Regards

Ayyapparaj

Former Member
0 Kudos

Thanks Raj,

in the getter return the size?? i didn't get it what you are saying.

its fine.

but can we two headers or two textviews, such that one is displayed on the left side showing the table name and the other one on the right side showing number of rows in the table. is it possible?

if not help me how to show both the table name and the row count on the table header

Thanks & regards,

Suresh

Former Member
0 Kudos

Hi,

Create an attribute of type String set the calculated property to true.

Ex : If my attribute name is AA1 following will be the getter

public java.lang.String getAA1(IPrivatePlayView.IAElement element)

{

//@@begin getAA1

StringBuffer header = " Table Name";

if(wdcontext.node<YourNode>() != null)

{

header.append(String.valueOf(wdcontext.node<YourNode>() .size()));

return header.toString();

}

return null;

//@@end

}

bind this attribute to the table header text property

Regards

Ayyapparaj

Former Member
0 Kudos

Hi raj,

I tried out the first one, i.e., by simplying binding the text property of the header to the calculated attribute as you said. its not showing any error.

but wen deployed, its not displaying anything.. its blank..

help me out....

Thanks&Regards

Suresh

Former Member
0 Kudos

Hi,

Create a context value attribute of type String and bind it to the table header property. After this write the following code in wdDoModifyView() method:

//Assuming Table is the name of the node bound to your table
if(! wdContext.nodeTable().isEmpty()){
   //assuming that TableHeaderText is the attribute
   wdContext.currentContextElement().setTableHeaderText("Header" + wdContext.nodeTable().size());
}

Regards,

Satyajit.

Former Member
0 Kudos

Thanks Satyajit,

its working..

but can we two headers or two textviews, such that one is displayed on the left side showing the table name and the other one on the right side showing number of rows in the table. is it possible?

if not help me how to show both the table name and the row count on the table header

Thanks & Regards,

Suresh