Re: How to update a CellTree after the model changes?
The problem is if the node is open, the open state is preserved (in
the code I showed below) and then it displays "no data". There
appears to be nothing in the code that will make the open icon go
away; isLeaf is never consulted again. I think that's a bug too,
right?
On Nov 8, 7:25 pm, John LaBanca <jlaba...@google.com> wrote:
> You should be able to call AbstractDataProvider.updateRowData() with just
> the one updated row value, which will only cause that row to refresh.
> However, there is a bug in CellTree (will be fixed in GWT 2.1.1) which
> always causes it to update the 0th item.
>
> Is there any way of making a node go from having children to having
>
> > no children again in a CellTree?
>
> You can set the row count in the child DataProvider to 0. The node won't be
> a leaf node, but it won't have any children. If you really want it to be a
> leaf node, you have to refresh the node using the same method above.
>
> Thanks,
> John LaBanca
> jlaba...@google.com
>
> On Mon, Nov 8, 2010 at 11:53 AM, Ed Merks <ed.me...@gmail.com> wrote:
> > I'm having a hard time understanding how I can update things like the
> > label of a node in the cell tree when I know its value has changed in
> > the model being viewed. Right now I have a rather brute force
> > approach: I update the entire set of children for the parent by
> > calling AbstractDataProvider.updateRowData. At least it works, but
> > it's like a sledge hammer. I have yet to figure out how to update
> > just the one child; maybe I just ran into bugs in the older pre-
> > release versions and have to try again. Also, I have to do similar
> > things if children are added, i.e., if a node y has a child z added,
> > and originally y had no children, I have to tell the parent node x of
> > y to update all its children so that it updates the expansion icon to
> > reflect that y is no longer a leaf. But, now matter how hard I wrack
> > my brain, I cannot find a way to make a node go from having children
> > back to being a leaf again. The only way I can get this to work is to
> > hack the code:
>
> > // Create a set of currently open nodes.
> > Set<Object> openNodes = new HashSet<Object>();
> > int childCount = nodeView.getChildCount();
> > int end = start + values.size();
> > for (int i = start; i < end && i < childCount; i++) {
> > CellTreeNodeView<?> child = nodeView.getChildNode(i);
> > // Ignore child nodes that are closed.
> > if (child.isOpen() && !child.isLeaf()) { ///////////////
> > <------ add the test to not save the open state if it's a leaf.
> > openNodes.add(child.getValueKey());
> > }
> > }
>
> > Is there any way of making a node go from having children to having no
> > children again in a CellTree?
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Google Web Toolkit" group.
> > To post to this group, send email to google-web-toolkit@googlegroups.com.
> > To unsubscribe from this group, send email to
> > google-web-toolkit+unsubscribe@googlegroups.com<google-web-toolkit%2Bunsubscribe@googlegroups.com>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/google-web-toolkit?hl=en.
>
>
--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home