Author |
Message |
18/11/2008 17:20:10
|
heyl
Power User
Joined: 10/01/2008 09:41:55
Messages: 267
Location: Ettlingen
Offline
|
Hi Björn,
is it possible that FIXGRIDListBinding.getItems() only gets the items that are currently visible in the grid?
Or maybe some more, but definetely not the complete list, as written in the docs.
I could swaer I have seen it working some time before.....
Did you change anything in that context???
kind regards
Frauke
|
|
|
18/11/2008 17:29:17
|
CaptainCasa
Power User
Joined: 21/11/2007 12:23:06
Messages: 5521
Offline
|
...getItems() returns the full list. getRows() (internal use only!) returns the visible items.
We swear! ;-)
Björn
|
Björn Müller, CaptainCasa GmbH |
|
|
19/11/2008 08:56:57
|
heyl
Power User
Joined: 10/01/2008 09:41:55
Messages: 267
Location: Ettlingen
Offline
|
Hi Björn,
yes, of course you are right. I think the problem is in a different place.
It concerns the FIXGRIDPivotListBinding.
I use the 'marked' property to display a checkbox in the pivot grid.
And I have a 'selectAll' funktion that walks the pivot tree (folded and unfolded subtrees) and collects all marked items.
And it 'looses' some of the marked items on it's way.
Probably the 'tree walker' function is not correct, but I can't tell because I don't know your implementation of the 'hidden items'.
oh, how should I explain???
Wouldn't you like to have a look via Yuuguu?
(at least it doesn't have anything to do with ActiveX
Frauke
|
|
|
20/11/2008 07:59:26
|
CaptainCasa
Power User
Joined: 21/11/2007 12:23:06
Messages: 5521
Offline
|
FIXGRIDPivotListBinding is managing FIXGRIDPivotItems, which can be folded, i.e. they may contain hidden items:
Code:
/**
* In case a pivot item is folded then it contains hidden items.
*/
public List<FIXGRIDPivotItem> getHiddenItems()
Björn
|
Björn Müller, CaptainCasa GmbH |
|
|
20/11/2008 08:47:11
|
heyl
Power User
Joined: 10/01/2008 09:41:55
Messages: 267
Location: Ettlingen
Offline
|
Hi Björn,
yes I know this, and I used getHiddenItems()
But still there is sometihing wrong.
I think it has something to do with the setMarked() and getMarked()functions.
ok: to have it more concrete:
What is the correct way to collect alll marked item?
This is how I did it, but it does not seem to work correctly.
Frauke
Code:
private Set<T> getMarkedItems(final List items) {
Set<T> results = new HashSet<T>();
for (int i = 0; i < items.size(); i++) {
T item = (T) items.get(i);
if (item != null) {
if (item.getFolded()) {
results.addAll(getMarkedItems(item.getHiddenItems()));
} else if (item.getMarked().booleanValue()) {
results.add(item);
}
}
}
return results;
}
|
|
|
20/11/2008 09:09:41
|
heyl
Power User
Joined: 10/01/2008 09:41:55
Messages: 267
Location: Ettlingen
Offline
|
Hi Björn,
after having a closer look at the problem, I suspect the HashSet to swallow up some of the FIXGRIDPivotItem items.
May be because they are so similar they have the same hash code.
Why did you use a HashSet as return type of the function getSelectedItems() instead of the good old List?
Frauke
|
|
|
20/11/2008 09:37:07
|
CaptainCasa
Power User
Joined: 21/11/2007 12:23:06
Messages: 5521
Offline
|
You should have got a nice stack trace when running your code (at least when having folded some nodes), the casting is not correct:
teh folded items are generated by the PIVOT grid, they are of type FIXGRIDPivotItem. Only the leaf-items are of the type that you fill into the grid.
Björn
PS: for inputting Code into the forum there is a "Code" button above the edit field
I extended the demo in my workplace:
Code:
private List<MyItem> getMarkedItems(List items)
{
List<MyItem> result = new ArrayList<MyItem>();
for (int i = 0; i < items.size(); i++)
{
FIXGRIDPivotItem item = (FIXGRIDPivotItem)items.get(i);
if (item != null)
{
if (item.getFolded())
{
result.addAll(getMarkedItems(item.getHiddenItems()));
}
else if (item.getMarked().booleanValue())
{
result.add((MyItem)item);
}
}
}
return result;
}
|
Björn Müller, CaptainCasa GmbH |
|
|
20/11/2008 09:52:57
|
heyl
Power User
Joined: 10/01/2008 09:41:55
Messages: 267
Location: Ettlingen
Offline
|
Hi Björn,
thanks so far.
Ok, I try your piece of code. (And by the way I did not get an exception at all!)
But still I have the problem that I need to return a Set in the function getSelectedItems() .
Code:
public Set<T> getSelectedItems() {
Set<T> results = getMarkedItems(getItems());
return results;
}
ok, in the preview the code was not fromatted correctly
But now it looks nice!
|
|
|
20/11/2008 09:59:51
|
CaptainCasa
Power User
Joined: 21/11/2007 12:23:06
Messages: 5521
Offline
|
There is a second method avilable with FIXGRIDListBinding:
Code:
/**
* Returns all selected items in the sequence they occur within the
* grid. Use getSelectedItems() returning a Set for normal operations - it
* is much faster. Only use this method when really requiring the
* order of items.
*/
public Collection<ItemClass> getSelectedItemsAsSequence()
Björn
|
Björn Müller, CaptainCasa GmbH |
|
|
20/11/2008 13:10:32
|
heyl
Power User
Joined: 10/01/2008 09:41:55
Messages: 267
Location: Ettlingen
Offline
|
Hi Björn,
the problem does not just concern the pivot grid, but FIXGRID in general.
I think the problem really is the HashSet in getSelectedItems().
You can never be sure that two or more elements don't have the same hash code.
Frauke
|
|
|
|