on 08-03-2006 9:32 AM
Heya,
I want quite simple to count the selected rows in my table....i looked in the forum and found a quite simple piece of code which would enable this:
int count = 0;
for (int j = 0, n = wdContext.nodeTask().size(); j < n; ++j) {
if (wdContext.nodeTask().getLeadSelection() == j
|| wdContext.nodeTask().isMultiSelected(j)) {
count++;
}
}
Looks quite simple but when i select multiple rows in my table....1 lead selection and 2 extra...the count still shows 1. I do count in the wdDoModifyView. Can anyone tell me why this aint working?
much thanks,
Hugo
Try this please, i think this will do the trick (not tried out)
int count = 0;
for (int i = 0, i<wdContext.nodeTask().size(); i++) {
if (wdContext.nodeTask().isSelected(i) {
count++;
}
}
wdComponentAPI.getMessageManager().reportSuccess("Count is: " +count);
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thx for the quick response.
Table is bound to the taskNode and is set to multiple....also tried both options but either keep returning count = 1 instead of more. When i clear the list the count says its 0 so thats ok.
isSelected() is deprecated so i rather not use that one...any other suggestions?
Hugo,
create a context attribute "counter" of type integer. Set the "calculated"-property of this attribute to "true" and "readonly"-property to "true". Go to the implementation of your view and add this to the method "getCounter(...)":
int counter = 0;
for (int i = 0; i < wdContext.nodeData().size(); i++) {
if(wdContext.nodeData().isMultiSelected(i)) {
counter++;
}
}
return counter;
Also set the "initializeLeadSelection"-property of your tables context node to "false" or set the counter attribute to "1" in wdDoInit().
Regards
Sebastian
When i try the count in another method, it does show the correct amount!
The problem is i show details when a task is selected and i want to clear the details when multiple are selected so in which event can i do this....i thought wdDoModifyView() would be good because it is triggered every time the view changes but apparently this isnt working. I also tried the count in onActionDetailsClicked() which is the event which is triggered when i select a row in the table but when i select the first row..it's triggered but when i add a second one...it's not.
Any ideas?
Hugo,
You've answered your question: do not use wdDoModifyView.
When multiple selection occured, a postback is sent to server. However, information sent with this postback does not contains updated values or selection changes. The only methods invoked with such postback are calculated attribute accessors and wdDoModifyView, but, as you see wdDoModifyiew is useless in this case.
Valery Silaev
EPAM Systems
Hi
try this
IPrivate<ViewName>.I<Name>Node nodeCheck=wdContext.node<Name>();
int count=0;
int size=nodeCheck.size();
for(int j=0;j<size;j++){
if(nodeCheck.isSelected(j)){
count=count+1;
}
}
Kind Regards
Mukesh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Is 'Task' really the node that is bound to your table (check table datasource)?
Is the selectionMode (table properties) set to multi?
Good luck,
Roelof
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
87 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
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.