on 03-27-2006 7:36 AM
Hi ,
I have a table and I want to get only selected rows in the table.
Please note that I can traverse entire rows and using isMultiSelected(int) can get the rows but using this I need to loop all the rows in the table.
So, is any api that I can use to directly get only the selected rows?
Thanks for your time.
Best regards,
Shiva.
Hi,
There is another method: U can use a HashMap object. A HashMap stores an object corresponding key.
It would be better if u use a checkbox in the table and create an event and bind it to the checkbox's onSelect property. Also add a parameter ("selectedCheckbox") of type boolean while creating the event. Also in the wdDoModify map the .addSourceMapping("checked","selectedCheckbox");.
Create a context of type HashMap (list) and in wdDoInit():
wdContext.currentContextElement().setList(new HashMap());
Now in the checkbox event handler write:
HashMap list = wdContext.currentContextElement().getList();
int pos = wdContext.node<name>().getLeadSelection();
if(selectedCheckbox)
{
list.put(""+pos,""+pos);
}
else
{
list.remove(""+pos);
}
Now HashMap will contain only those row which are selected.
Now to populate the values:
Set set = wdContext.currentContextElement().keySet();
Object[] obj = set.toArray();
IPrivate<view>.I<node>Element element;
for(int i=0;obj.length;i++)
{
element = wdContext.node<name>().get<node>ElementAt(Integer.parseInt((String)ojb<i>));
}
Here the obj array will have value of keys present in the HashMap. As key is the selected row stored as String so we convert it into int.
Regards,
Piyush.
ps: the code might require some editing, but i guess u r clear about the logic.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Shiva,
I think there can be a work around, though not a pretty one.
There's an event called onLeadSelect for every table UI element. So you can handle this event to save the current lead selection of the node bound to your table. Then later you can access only these rows.
But this might be slower than actually iterating through the rows.
Regards,
Satyajit.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Shiva,
Currently no, you have to iterate collection.
VS
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Shiva,
Try to use this:
for (int j = 0, n = wdContext.nodeRows().size(); j < n; ++j)
{
if (wdContext.nodeRows().getLeadSelection() == j
|| wdContext.nodeRows().isMultiSelected(j)
{
/* row at index j is selected */
}
}
So, there is no other way except this.
Best regards, Maksim Rashchynski.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
89 | |
10 | |
9 | |
9 | |
9 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.