I have a tree widget shown as follows
Fruits
Apple
Red apple
Yellow apple
Orange
Vegetable
Okra
Chili
Now, I would like to set the background color TreeItems, such that it
spans the entire length (in x-direction) of tree widget. I am using
the following method:
public void setTreeItemBackgroundColor(final TreeItem t, final String
color) {
Element table = DOM.getFirstChild(t.getElement());
Element tbody = DOM.getFirstChild(table);
Element tr = DOM.getFirstChild(tbody);
DOM.setStyleAttribute(tr, "backgroundColor", color);
}
This does set the background color, but only for the extent of
TreeItem text and not the entire x-direction of tree widget. See
picture below:
<------------------------> // This is what I want, I want
background color till full x-extent of tree
<-----> // I am getting background color
till here, only till where text is
Fruits
Apple
Red apple
Yellow apple
Orange
Vegetable
Okra
Chili
How can I achieve this? Thanks in advance.
Joster
Does that do what you want it to do?
-krispy
I want the entire row back-ground color to be set, not just the text
portion of the row. Let me know if my description is unclear.
Joster
// BackGround
.gwt-Tree {
background-color: darkred;
}
// Text ITEM
.gwt-Tree .gwt-TreeItem {
font-size: 80%;
background-color: olivedrab;
cursor: default;
}
// Selected Text Item
.gwt-Tree .gwt-TreeItem-selected {
background-color: red;
===================================================================
package com.mycompany.project.client;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Tree;
import com.google.gwt.user.client.ui.TreeItem;
public class test extends Composite {
public test() {
final HorizontalPanel horizontalPanel = new
HorizontalPanel();
initWidget(horizontalPanel);
final Tree tree = new Tree();
horizontalPanel.add(tree);
tree.setSize("0", "0");
final TreeItem treeItem = new TreeItem("New item");
tree.addItem(treeItem);
final TreeItem treeItem_1 = new TreeItem("New item");
treeItem.addItem(treeItem_1);
final TreeItem treeItem_4 = new TreeItem("New item");
treeItem_1.addItem(treeItem_4);
final TreeItem treeItem_2 = new TreeItem("New item");
tree.addItem(treeItem_2);
final TreeItem treeItem_3 = new TreeItem("New item");
tree.addItem(treeItem_3);
}
}
===========================================================================
public class MainEntryPoint implements EntryPoint {
private Button clickMeButton;
public void onModuleLoad() {
test tree = new test();
tree.setWidth("100%");
tree.setHeight("100%");
RootPanel.get().add(tree);
}
}
===========================================
On 9월5일, 오후1시04분, sunnybaek <sunnyb...@epozen.com> wrote:
> Or this ????
>
> ===================================================================
> package com.mycompany.project.client;
>
> import com.google.gwt.user.client.ui.Composite;
> import com.google.gwt.user.client.ui.HorizontalPanel;
> import com.google.gwt.user.client.ui.Tree;
> import com.google.gwt.user.client.ui.TreeItem;
>
> public class test extends Composite {
>
> public test() {
>
> final HorizontalPanel horizontalPanel = new HorizontalPanel();
> initWidget(horizontalPanel);
>
> final Tree tree = new Tree();
> horizontalPanel.add(tree);
> tree.setSize("0", "0");
>
> final TreeItem treeItem = new TreeItem("New item");
> tree.addItem(treeItem);
>
> final TreeItem treeItem_1 = new TreeItem("New item");
> treeItem.addItem(treeItem_1);
>
> final TreeItem treeItem_4 = new TreeItem("New item");
> treeItem_1.addItem(treeItem_4);
>
> final TreeItem treeItem_2 = new TreeItem("New item");
> tree.addItem(treeItem_2);
>
> final TreeItem treeItem_3 = new TreeItem("New item");
> tree.addItem(treeItem_3);
> }
>
> }
>
> ===================================================================
Tree widget adds indentation to child nodes (and its child ...). So, I
want the entire x-extent to be have a background color.
For example
<------------> // Background-color for TreeItem == Fruit
Fruit
Apple
Orange
Joster
On Sep 5, 3:18 pm, "John Webster" <joster.j...@gmail.com> wrote:
> To demo example of what I want, I have attached a picture, hope this adds
> clarity to my request.
>
> Joster
>
> > > > > > > > DOM.setStyleAttribute(tr, "backgroundColor", color);
>
> > > > > > > > }
>
> > > > > > > > This does set the background color, but only for the extent of
> > > > > > > > TreeItem text and not the entire x-direction of tree widget.
> > See
> > > > > > > > picture below:
>
> > > > > > > > <------------------------> // This is what I want,
> > I want
> > > > > > > > background color till full x-extent of tree
> > > > > > > > <-----> // I am getting
> > background color
> > > > > > > > till here, only till where text is
> > > > > > > > Fruits
> > > > > > > > Apple
> > > > > > > > Red apple
> > > > > > > > Yellow apple
> > > > > > > > Orange
> > > > > > > > Vegetable
> > > > > > > > Okra
> > > > > > > > Chili
>
> > > > > > > > How can I achieve this? Thanks in advance.
>
> > > > > > > > Joster
>
>
>
> tree.png
> 5KViewDownload
.TreeItemBackground {
background-color: yellow;
width: 100%;
}
> On 9/5/07, Chad Bourque <chad...@gmail.com> wrote:
>
>
>
> > Joster,
>
> > Just put the TreeItems in the VerticalPanel (many VPs) and add the VPs to
> > the Tree.
>
> > HTH,
> > Chad
>
> > On 9/5/07, John Webster <joster.j...@gmail.com> wrote:
>
> > > Thanks.
>
> > > If I put the Tree inside VerticalPanel and set its background color, the
> > > entire tree changes its background color. I only want to set background
> > > color for TreeItems (not the entire tree).
>
> > > Joster
>
> ...
>
> read more »
Help anyone?
Joster
> ...
>
> read more