on 11-22-2007 7:24 AM
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
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.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
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
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.
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
User | Count |
---|---|
84 | |
25 | |
12 | |
9 | |
6 | |
6 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.