Giter Site home page Giter Site logo

tree-grid's Introduction

Build Status Published on Vaadin  Directory Stars on Vaadin Directory

Vaadin TreeGrid add-on

TreeGrid is a UI component add-on for Vaadin 7. It adds the ability to display and edit hierarchical data source in the Grid component (similar to TreeTable's extension to Table).

https://vaadin.com/directory#!addon/vaadin-treegrid

Getting started

Live Demo ↗

Here is a simple example on how to try out the add-on component:

import org.vaadin.treegrid.container.Measurable;
import com.vaadin.data.Collapsible;
// ...

public class DemoContainer extends HierarchicalContainer implements Collapsible, Measurable {
    // ...
}
public class DemoUI extends UI {
    // ...

    @Override
    protected void init(VaadinRequest request) {
        final TreeGrid grid = new TreeGrid();

        DemoContainer container = new DemoContainer();
        grid.setContainerDataSource(container);

        grid.setHierarchyColumn(DemoContainer.NAME_PROPERTY);

        grid.setColumnReorderingAllowed(true);

        // ...
    }
}

For a more comprehensive example, see treegrid-demo/src/main/java/org/vaadin/treegrid/demo/DemoUI.java

Building and running the add-on project

git clone https://github.com/vaadin/tree-grid
mvn clean install
cd treegrid-demo
mvn jetty:run

To see the demo, navigate to http://localhost:8080/

Development with Eclipse IDE

For further development of this add-on, the following tool-chain is recommended:

  • Eclipse IDE
  • m2e wtp plug-in (install it from Eclipse Marketplace)
  • Vaadin Eclipse plug-in (install it from Eclipse Marketplace)
  • JRebel Eclipse plug-in (install it from Eclipse Marketplace)
  • Chrome browser

Importing project

Choose File > Import... > Existing Maven Projects

Note that Eclipse may give "Plugin execution not covered by lifecycle configuration" errors for pom.xml. Use "Permanently mark goal resources in pom.xml as ignored in Eclipse build" quick-fix to mark these errors as permanently ignored in your project. Do not worry, the project still works fine.

Debugging server-side

If you have not already compiled the widgetset, do it now by running vaadin:install Maven target for treegrid-root project.

If you have a JRebel license, it makes on the fly code changes faster. Just add JRebel nature to your treegrid-demo project by clicking project with right mouse button and choosing JRebel > Add JRebel Nature

To debug project and make code modifications on the fly in the server-side, right-click the treegrid-demo project and choose Debug As > Debug on Server. Navigate to http://localhost:8080/treegrid-demo/ to see the application.

Debugging client-side

Debugging client side code in the treegrid-demo project:

  • run "mvn vaadin:run-codeserver" on a separate console while the application is running
  • activate Super Dev Mode in the debug window of the application or by adding ?superdevmode to the URL
  • You can access Java-sources and set breakpoints inside Chrome if you enable source maps from inspector settings.

Release notes

Version 0.7.0

  • Basic functionality for displaying hierarchical data in Grid
  • CSS configurable hierarchy indicators
  • Expand/collapse functionality on mouse click
  • Programmatically settable hierarchy column
  • Keyboard navigation (Alt/Option + Arrow keys)
  • Support for custom renderer on hierarchy column
  • Support for custom depth calculation logic
  • Support for custom collapse logic

Issue tracking

The issues for this add-on are tracked on the https://github.com/vaadin/tree-grid/issues page. All bug reports and feature requests are appreciated.

Contributions

Contributions are welcome, but there are no guarantees that they are accepted as such. Process for contributing is the following:

  • Fork this project
  • Create an issue to this project about the contribution (bug or feature) if there is no such issue about it already. Try to keep the scope minimal.
  • Develop and test the fix or functionality carefully. Only include minimum amount of code needed to fix the issue.
  • Refer to the fixed issue in commit
  • Send a pull request for the original project
  • Comment on the original issue that you have implemented a fix for it

License & Author

This add-on is distributed under Apache License version 2.0 Vaadin TreeGrid is written by Vaadin Ltd.

tree-grid's People

Contributors

alvarezguille avatar binbalenci avatar juhopiirainen avatar magnolia-integration avatar tatulund avatar wbadam avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

tree-grid's Issues

Method when user click on node in a treegrid

Hi,

I want to know if it is possible to have a method to know when user click on node in a treegrid. There is the method addItemClickListener to know when user click on item in a line of the treegrid but there is no way to know when user click on node.

Could you help me please.

Filtering column treegrid

I have an enhancement to propose.

I want add a column filter to filter my first column. but it doesnt work. So can you add on your add-on the code to filter column.

For the moment, I use this code to filter a column

image

But it doesnt work.

Support hierarchical Multiselection-Mode

It would be nice to support multiselection-mode out of the box.
Currently if turning on multiselection-mode I can select multiple, single rows.

From a usability point of view when using a tree for selecting items, I would expect all children to get (de)selected if a parents checkbox is clicked.

Additionally an indeterminate checkbox should be used if only parts of the children are selected.

Treegrid doesn't work correctly with addItemClickListener

I use Treegrid and I want use the method addItemClickListener but it doesn't work correctly.

For example, when I click on a line, I have the code on the method addItemClickListener who is executed but when I click on the text on a line, there is no code who is executed.

I don't have this problem with the grid but with the treegrid I have the problem.

First picture, I click on the line not on the text, it works

image

Second picture, I click on the line but on the text, it doesn't work

image

I send you the project test

GridTest.zip

Rename repo to “TreeGrid”

The current repo name suggests that it would be a part of our web components collection, together with vaadin-grid, vaadin-combo-box, vaadin-date-picker and so on, which probably confuses some users.

I suggest we rename it to reflect the Java class explicitly.

will not compile under Vaadin 7.7.7

since Vaadin 7.7.7

com.vaadin.client.widgets.Grid.getEscalator()

is public

so GWT will not compile anymore because

org.vaadin.treegrid.client.TreeGrid.getEscalator()

is protected

[INFO] Compiling module AppWidgetset
[INFO]    Tracing compile failure path for type 'org.vaadin.treegrid.client.TreeGrid'
[INFO]       [ERROR] Errors in 'jar:file:/C:/Users/MyUser/.m2/repository/com/vaadin/vaadin-treegrid/0.7.3/vaadin-treegrid-0.7.3.jar!/org/vaadin/treegrid/client/TreeGrid.java'
[INFO]          [ERROR] Line 23: Cannot reduce the visibility of the inherited method from Grid<JsonObject>
[INFO]    [ERROR] Aborting compile due to errors in some input files

for backward compatibility yours should be made public too

Visibility Changed Event not working

It seems that hiding/showing columns is not working as it should. (v0.7.5, v0.7.6)

For a specific column I set: column.setHidable(true);
If I'm trying to hide/un-hide it from the UI it will raise an exception and I won't be able to use treeGrid.addColumnVisibilityChangeListener method to add specific logic. The column is hided but the exception is preventing me using the raised event in other scopes.

The exception is next:

java.lang.IllegalAccessException: Class org.vaadin.treegrid.TreeGrid$1 can not access a member of class com.vaadin.ui.Grid with modifiers ""
	at sun.reflect.Reflection.ensureMemberAccess(Reflection.java:102)
	at java.lang.reflect.AccessibleObject.slowCheckMemberAccess(AccessibleObject.java:296)
	at java.lang.reflect.AccessibleObject.checkAccess(AccessibleObject.java:288)
	at java.lang.reflect.Method.invoke(Method.java:491)
	at org.vaadin.treegrid.TreeGrid$1.columnVisibilityChanged(TreeGrid.java:264)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at com.vaadin.server.ServerRpcManager.applyInvocation(ServerRpcManager.java:158)
	at com.vaadin.server.ServerRpcManager.applyInvocation(ServerRpcManager.java:119) ......... 

I've tried it with versions of Vaadin 7.7.9 and 7.7.10.

TreeGrid nullpointer exception triggered when expanding a parent node

I believe this has something to do with the styletheme when using a component column with multiple selection. If using the standard column construct, it works fine. I am including the code and stack trace below. Thank you.

` /**
* @return the tree
*/
private TreeGrid getTree() {
if (tree == null) {
tree = new TreeGrid();
tree.setSizeFull();
tree.setHeightByRows(25);

		tree.setSelectionMode(SelectionMode.MULTI);

		tree.addColumn(SegmentValue::getKey).setId("key").setCaption("LINE").setSortable(false);
		tree.addComponentColumn(sv -> {
			final LabelButton lineSegment = new LabelButton();
			
			lineSegment.setValue(sv.getValue().toString());
			lineSegment.addStyleName(LabelButtonStyles.PENCIL_WHEN_CLICKABLE);
			lineSegment.setClickable(sv.hasErrors());

			lineSegment.addLabelClickListener(listener -> {
				System.out.println(x12.findSegment(sv.getValue().toString()));
			});
			return lineSegment;
		}).setId("value").setCaption("LINE VALUE").setSortable(false);
		/*
		 * Tree grid header
		 */
		HeaderRow header = tree.prependHeaderRow();
		header.join(header.getCell("key"), header.getCell("value"))
				.setHtml(VaadinIcons.EXCLAMATION.getHtml() + "<b>ERROR</b>");
		/*
		 * Set data provider
		 */
		tree.setDataProvider(getDataProvider());
	}
	return tree;
}

/**
* @return the toolBar
*/
private SegmentSearchToolBar getToolBar() {
if (toolBar == null) {
toolBar = new SegmentSearchToolBar();
toolBar.getSearchButton().addClickListener(listener -> {
tree.collapse(treeData.getRootItems());
tree.deselectAll();

			final String searchValue = toolBar.getValue().trim();
			if (StringUtils.isNotEmpty(searchValue)) {
				tree.expand(treeData.getRootItems());
				selectSegment(searchValue, treeData.getRootItems());
			}
		});
	}
	return toolBar;
}`

java.lang.NullPointerException: Cannot provide an id for a null item.
at java.util.Objects.requireNonNull(Unknown Source)
at com.vaadin.data.provider.DataProvider.getId(DataProvider.java:132)
at com.vaadin.data.provider.HierarchyMapper.doCollapse(HierarchyMapper.java:155)
at com.vaadin.data.provider.HierarchicalDataCommunicator.doCollapse(HierarchicalDataCommunicator.java:173)
at com.vaadin.ui.TreeGrid.lambda$registerTreeGridRpc$275f28ba$1(TreeGrid.java:179)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.vaadin.server.ServerRpcManager.applyInvocation(ServerRpcManager.java:155)
at com.vaadin.server.ServerRpcManager.applyInvocation(ServerRpcManager.java:116)
at com.vaadin.server.communication.ServerRpcHandler.handleInvocation(ServerRpcHandler.java:445)
at com.vaadin.server.communication.ServerRpcHandler.handleInvocations(ServerRpcHandler.java:410)
at com.vaadin.server.communication.ServerRpcHandler.handleRpc(ServerRpcHandler.java:274)
at com.vaadin.server.communication.PushHandler.lambda$new$1(PushHandler.java:145)
at com.vaadin.server.communication.PushHandler.callWithUi(PushHandler.java:235)
at com.vaadin.server.communication.PushHandler.onMessage(PushHandler.java:520)
at com.vaadin.server.communication.PushAtmosphereHandler.onMessage(PushAtmosphereHandler.java:87)
at com.vaadin.server.communication.PushAtmosphereHandler.onRequest(PushAtmosphereHandler.java:77)
at org.atmosphere.cpr.AsynchronousProcessor.action(AsynchronousProcessor.java:223)
at org.atmosphere.cpr.AsynchronousProcessor.suspended(AsynchronousProcessor.java:115)
at org.atmosphere.container.Servlet30CometSupport.service(Servlet30CometSupport.java:67)
at org.atmosphere.cpr.AtmosphereFramework.doCometSupport(AtmosphereFramework.java:2284)
at org.atmosphere.websocket.DefaultWebSocketProcessor.dispatch(DefaultWebSocketProcessor.java:593)
at org.atmosphere.websocket.DefaultWebSocketProcessor$3.run(DefaultWebSocketProcessor.java:345)
at org.atmosphere.util.VoidExecutorService.execute(VoidExecutorService.java:101)
at org.atmosphere.websocket.DefaultWebSocketProcessor.dispatch(DefaultWebSocketProcessor.java:340)
at org.atmosphere.websocket.DefaultWebSocketProcessor.invokeWebSocketProtocol(DefaultWebSocketProcessor.java:447)
at org.atmosphere.container.JSR356Endpoint$3.onMessage(JSR356Endpoint.java:272)
at org.atmosphere.container.JSR356Endpoint$3.onMessage(JSR356Endpoint.java:269)
at org.apache.tomcat.websocket.WsFrameBase.sendMessageText(WsFrameBase.java:395)
at org.apache.tomcat.websocket.server.WsFrameServer.sendMessageText(WsFrameServer.java:119)
at org.apache.tomcat.websocket.WsFrameBase.processDataText(WsFrameBase.java:495)
at org.apache.tomcat.websocket.WsFrameBase.processData(WsFrameBase.java:294)
at org.apache.tomcat.websocket.WsFrameBase.processInputBuffer(WsFrameBase.java:133)
at org.apache.tomcat.websocket.server.WsFrameServer.onDataAvailable(WsFrameServer.java:82)
at org.apache.tomcat.websocket.server.WsFrameServer.doOnDataAvailable(WsFrameServer.java:171)
at org.apache.tomcat.websocket.server.WsFrameServer.notifyDataAvailable(WsFrameServer.java:151)
at org.apache.tomcat.websocket.server.WsHttpUpgradeHandler.upgradeDispatch(WsHttpUpgradeHandler.java:148)
at org.apache.coyote.http11.upgrade.UpgradeProcessorInternal.dispatch(UpgradeProcessorInternal.java:54)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:53)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:796)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1372)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Unknown Source)

Exception when reordering columns

GridState#columnOrder is not accessible via getDeclaredField() because it is in super class.

java.lang.NoSuchFieldException: columnOrder
	at java.lang.Class.getDeclaredField(Class.java:2070)
	at com.vaadin.ui.Grid$3.columnsReordered(Grid.java:4716)

Unable to expand tree after upgrade to Vaadin 7.7.16

After upgrading Vaadin from 7.7.15 to 7.7.16 (currently the newest Vaadin 7 version), TreeGrid stopped to work correctly. Now the arrows are missing which makes it impossible to expand collapsed data.

The bug can be easily reproduced using treegrid-demo application. It works correctly when compiled using Vaadin version up to 7.7.15. When using Vaadin 7.7.16 it looks like in attachment.
tree-grid-vaadin-7 7 16

AppWidgetSet compile fails - Vaadin 8.2.1 - TreeGrid 0.7.7

Here is widget set compilation log:

> [INFO] auto discovered modules [AppWidgetset]
> [INFO] Using com.vaadin:vaadin-client-compiler version 8.2.1
> [INFO] Compiling module AppWidgetset
> [INFO]    Tracing compile failure path for type 'org.vaadin.treegrid.client.TreeGridConnector'
> [INFO]       [ERROR] Errors in 'jar:file:/C:/Users/Faruk/.m2/repository/com/vaadin/vaadin-treegrid/0.7.7/vaadin-treegrid-0.7.7.jar!/org/vaadin/treegrid/client/TreeGridConnector.java'
> [INFO]          [ERROR] Line 26: The method getWidget() of type TreeGridConnector must override or implement a supertype method
> [INFO]          [ERROR] Line 101: GridConnector cannot be resolved to a type
> [INFO]          [ERROR] Line 128: The method getChildren() is undefined for the type TreeGridConnector
> [INFO]          [ERROR] Line 32: GridConnector cannot be resolved to a type
> [INFO]          [ERROR] Line 31: The method getState() of type TreeGridConnector must override or implement a supertype method
> [INFO]          [ERROR] Line 40: The method onStateChanged(StateChangeEvent) of type TreeGridConnector must override or implement a supertype method
> [INFO]          [ERROR] Line 121: The method onUnregister() of type TreeGridConnector must override or implement a supertype method
> [INFO]          [ERROR] Line 21: GridConnector cannot be resolved to a type
> [INFO]          [ERROR] Line 122: GridConnector cannot be resolved to a type
> [INFO]          [ERROR] Line 41: GridConnector cannot be resolved to a type
> [INFO]          [ERROR] Line 27: GridConnector cannot be resolved to a type
> [INFO]          [ERROR] Line 11: The import com.vaadin.client.connectors.GridConnector cannot be resolved
> [INFO]          [ERROR] Line 100: The method init() of type TreeGridConnector must override or implement a supertype method
> [INFO]          [ERROR] Line 109: The method getRowKey(JsonObject) is undefined for the type new ClickableRenderer.RendererClickHandler<JsonObject>(){}
> [INFO]    Tracing compile failure path for type 'org.vaadin.treegrid.client.HierarchyDataGeneratorConnector'
> [INFO]       [ERROR] Errors in 'jar:file:/C:/Users/Faruk/.m2/repository/com/vaadin/vaadin-treegrid/0.7.7/vaadin-treegrid-0.7.7.jar!/org/vaadin/treegrid/client/HierarchyDataGeneratorConnector.java'
> [INFO]          [ERROR] Line 1: The type com.vaadin.server.communication.data.DataGenerator cannot be resolved. It is indirectly referenced from required .class files
> [INFO]    Tracing compile failure path for type 'org.vaadin.treegrid.client.NavigationExtensionConnector'
> [INFO]       [ERROR] Errors in 'jar:file:/C:/Users/Faruk/.m2/repository/com/vaadin/vaadin-treegrid/0.7.7/vaadin-treegrid-0.7.7.jar!/org/vaadin/treegrid/client/NavigationExtensionConnector.java'
> [INFO]          [ERROR] Line 56: The method getRowKey(JsonObject) is undefined for the type TreeGridConnector
> [INFO]          [ERROR] Line 93: The return type is incompatible with Connector.getParent()
> [INFO]          [ERROR] Line 67: The method getRowKey(JsonObject) is undefined for the type TreeGridConnector
> [INFO]          [ERROR] Line 93: The return type is incompatible with AbstractConnector.getParent()
> [INFO]       [ERROR] Errors in 'jar:file:/C:/Users/Faruk/.m2/repository/com/vaadin/vaadin-treegrid/0.7.7/vaadin-treegrid-0.7.7.jar!/org/vaadin/treegrid/client/TreeGridConnector.java'
> [INFO]          [ERROR] Line 26: The method getWidget() of type TreeGridConnector must override or implement a supertype method
> [INFO]          [ERROR] Line 101: GridConnector cannot be resolved to a type
> [INFO]          [ERROR] Line 128: The method getChildren() is undefined for the type TreeGridConnector
> [INFO]          [ERROR] Line 32: GridConnector cannot be resolved to a type
> [INFO]          [ERROR] Line 31: The method getState() of type TreeGridConnector must override or implement a supertype method
> [INFO]          [ERROR] Line 40: The method onStateChanged(StateChangeEvent) of type TreeGridConnector must override or implement a supertype method
> [INFO]          [ERROR] Line 121: The method onUnregister() of type TreeGridConnector must override or implement a supertype method
> [INFO]          [ERROR] Line 21: GridConnector cannot be resolved to a type
> [INFO]          [ERROR] Line 122: GridConnector cannot be resolved to a type
> [INFO]          [ERROR] Line 41: GridConnector cannot be resolved to a type
> [INFO]          [ERROR] Line 27: GridConnector cannot be resolved to a type
> [INFO]          [ERROR] Line 11: The import com.vaadin.client.connectors.GridConnector cannot be resolved
> [INFO]          [ERROR] Line 100: The method init() of type TreeGridConnector must override or implement a supertype method
> [INFO]          [ERROR] Line 109: The method getRowKey(JsonObject) is undefined for the type new ClickableRenderer.RendererClickHandler<JsonObject>(){}
> [INFO]    [ERROR] Aborting compile due to errors in some input files

TreeGrid renders flat hierarchy

I've built my first TreeGrid component and I can't get TreeGrid to display the hierarchy. The table is rendered flat without any tree structure.

The debug in my container class indicates the items are added with the proper hierarchy.

I'm using TreeGrid 0.7.4 and Vaadin 7.7.7.

The class files are available in this forum post:
https://vaadin.com/forum#!/thread/15399932

vaadin-treegrid shows "[object Object]" tooltips when using MPR

image

Hi. We have an app on Vaadin 7.7.32 and have a lot of instances of treegrids (vaadin-treegrid addon 0.7.8).
Since we added MPR (version through bom) and Vaadin 23.3.2 we have weird tooltips in the treegrids showing "[object Object]".
All legacy views are wrapped in flow routes.

It can even be reproduced with simple code like

HierarchicalContainer container = new HierarchicalContainer();
container.addContainerProperty("1", String.class, null);
container.addContainerProperty("2", String.class, null);
TreeGrid g = new TreeGrid();
g.setContainerDataSource(container);
g.setWidth("100%");
g.setHeight("300px");
g.addRow("aaa", "bbb");

or

HierarchicalContainer cont = new HierarchicalContainer();
cont.addContainerProperty("aa", String.class, null);
cont.addContainerProperty("bb", String.class, null);
Item item = cont.addItem("numbers");
item.getItemProperty("aa").setValue("first");
item.getItemProperty("bb").setValue("second");
TreeGrid grid = new TreeGrid();
grid.setContainerDataSource(cont);
grid.setWidth("100%");
grid.setHeight("300px");

When setting a cell tooltip ourselves, that one is taken, so that replaces the ugly "[object Object]": g.setCellDescriptionGenerator((Grid.CellDescriptionGenerator) cell -> "cell");
When our setCellDescriptionGenerator tooltip returns null or "", it displays [object Object] again.....

We did not have this behaviour before the MPR & Vaadin 23 addition. I looked through https://github.com/vaadin/tree-grid/ but could not find what could cause this. Nothing is logged in the browser.
It is really the v-tooltip that is displaying the text.

Support for HierarchicalContainer

Why does GridTree require its own GridTreeContainer instead of using HierarchicalContainer? Most of our code already generates HierarchicalContainer so creating yet another container seems like a lot of extra work.

Frozen columns BUG

I try to use setFrozenColumnCount(1); but it doesn't work (v 0.7.3).

I would like to freeze only the first, hierarchy column. I disabled the built-in selection checkbox column. I tested with values: -1;0;1, but has no effect. With value 2 the first two columns wil be frozen.

srcoll row get blank when grid height is not a fix height.

i hava a grid that contains 50 row, when the grid height is set to a fix pixels, evernthing goes well.
final VerticalLayout layout = new VerticalLayout();
layout.setSpacing(true);
layout.setMargin(true);
layout.setSizeFull();
final TreeGrid grid = new TreeGrid();
grid.setWidth("100%");
grid.setHeight(600, Unit.PIXELS);
the result:
well

then i set the grid height to 70%;
final VerticalLayout layout = new VerticalLayout();
layout.setSpacing(true);
layout.setMargin(true);
layout.setSizeFull();
final TreeGrid grid = new TreeGrid();
grid.setWidth("100%");
grid.setHeight("70%");
the srcoll bottom row is blank like
good

click the blank row ,then the row go normal.

Select items that are collapsed

It should be possible to select items that are not showing at the moment. My logic selects all the child items when a parent item is selects in multiselection mode.
The problem is that containsId method in ContainerCollapsibleWrapper only searches for the id in the visible items but should search on all items of the container that are not filtered out.

public boolean containsId(Object itemId) {
return this.visibleItemIds.contains(itemId);
}

Error Javascript with treegrid

I have a problem with your add-on with the browser :

I have a page that contains a treegrid and when I go to another page of my application, the browser (IE, Chrome...) send an error :

SEVERE: Widget is still attached to the DOM after the connector (HorizontalLayoutConnector (58)) has been unregistered. Widget was removed.

I have this error, when I use a treegrid.

Could you to intervene please.

Add possibilities for sorting and filtering

Currently (as far as I have used it), it is not possible to filter or sort if I just pass in a simple HierarchicalContainer to setContainerDataSource.

In that case the container is wrapped inside a ContainerCollapsibleWrapper.

I had to create myself a wrapper that I can pass in to the method that extends the ContainerCollapsibleWrapper:

public class FilterableSortableCollapsibleWrapper extends ContainerCollapsibleWrapper
    implements Container.Sortable, Container.Filterable {

  private final Sortable sortable;
  private final Filterable filterable;

  public FilterableSortableCollapsibleWrapper(Indexed container) {
    super(container);
    if (!(container instanceof Sortable)) {
      throw new IllegalArgumentException("Container must implement the Sortable interface");
    } else if (!(container instanceof Filterable)) {
      throw new IllegalArgumentException("Container must implement the Filterable interface");
    } else {
      this.sortable = (Sortable) container;
      this.filterable = (Filterable) container;
    }
  }

  @Override
  public void sort(Object[] propertyId, boolean[] ascending) {
    sortable.sort(propertyId, ascending);
  }

  @Override
  public Collection<?> getSortableContainerPropertyIds() {
    return sortable.getSortableContainerPropertyIds();
  }

  @Override
  public void addContainerFilter(Filter filter) throws UnsupportedFilterException {
    filterable.addContainerFilter(filter);
  }

  @Override
  public void removeContainerFilter(Filter filter) {
    filterable.removeContainerFilter(filter);
  }

  @Override
  public void removeAllContainerFilters() {
    filterable.removeAllContainerFilters();
  }

  @Override
  public Collection<Filter> getContainerFilters() {
    return filterable.getContainerFilters();
  }
}

A better implementation wuold possibly use the decorator pattern and provide a decorator for each, filtering and sorting and use them inside the TreeGrid constructor for decorating the collapsible wrapper.

Bug display in TreeGrid

I have a problem with your add-on Vaadin.

I have a grid in a window. The grid contains two parent node and each parent node contains some child node.

image

When all nodes are fold up and I unfold one node, I can have a bug display in treegrid like this

image

image

Nevertheless, I don't have this problem when the grid is not in a window and when I use Chrome. The problem is just with IE.

image

TreeGridTest.zip

Sincerely.

Compilation error with Vaadin 7.7.9

TreeGrid 0.7.4 fails to compile under Vaadin 7.7.9 due to the following exception:

[INFO] --- vaadin-maven-plugin:7.7.9:compile (default) @ imc-ui ---
[INFO] auto discovered modules [AppWidgetset]
[INFO] Using com.vaadin:vaadin-client version 7.7.9
[INFO] Using com.vaadin:vaadin-client-compiler version 7.7.9
[INFO] Compiling module AppWidgetset
[INFO]    Tracing compile failure path for type 'org.vaadin.treegrid.client.TreeGridConnector'
[INFO]       [ERROR] Errors in 'jar:file:/Users/bhorne/.m2/repository/com/vaadin/vaadin-treegrid/0.7.4/vaadin-treegrid-0.7.4.jar!/org/vaadin/treegrid/client/TreeGridConnector.java'
[INFO]          [ERROR] Line 164: Referencing field 'com.vaadin.client.widgets.Grid.clickEvent': unable to resolve field in class 'com.vaadin.client.widgets.Grid'
[INFO]    [ERROR] Aborting compile due to errors in some input files
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------

Unfold / fold node : lost change

I have a problem with the treegrid.

When I unfold a node and I edit a line and save the change and I fold the same node and unfold the same node, i lost the change of my edit of my line.

I have test your component at this adress http://adam.app.fi/treegrid/

image

I edit one line and save it

image

I fold and unfold the same node and I lost change.

image

image

Hierarchy column rendering issue when used with TabSheets

Hi, we have come across an issue with TreeGrid when added onto a TabSheet.
The problem occurs when there exists other columns positioned to the left of the hierarchy column, and for whatever reason, these columns are hidden.

image

image

Firstly, notice how the expand/collapse icons go missing from the hierarchy column when we hide the last modified column.

Secondly, when we switch to the hello and then back to the world tab, the hierarchy column suddenly comes up blank.

image

image

From our investigation thus far, the problem seems to be that when switching between tabs, the grid will refresh any grid rows, and in doing so attempt to retrieve the widget in the cell. But the widget it retrieves will be of the type of the inner renderer instead of the HierarchyItem that the HierarchyRenderer requires. With the exception of TextRenderer (which throws an assertion error), a ClassCastException results.

Can anyone please assist?

`

package org.vaadin.treegrid.demo;

import java.util.Arrays;

import javax.servlet.annotation.WebServlet;

import org.vaadin.treegrid.TreeGrid;

import com.vaadin.annotations.Theme;
import com.vaadin.annotations.Title;
import com.vaadin.annotations.VaadinServletConfiguration;
import com.vaadin.data.Property;
import com.vaadin.server.VaadinRequest;
import com.vaadin.server.VaadinServlet;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Button.ClickListener;
import com.vaadin.ui.ComboBox;
import com.vaadin.ui.Grid;
import com.vaadin.ui.Grid.Column;
import com.vaadin.ui.TabSheet;
import com.vaadin.ui.UI;
import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.renderers.ImageRenderer;

@Theme("demo")
@Title("Vaadin TreeGrid Add-on Demo")
@SuppressWarnings("serial")
public class DemoUI extends UI {

    @WebServlet(value = "/*", asyncSupported = true)
    @VaadinServletConfiguration(productionMode = false, ui = DemoUI.class, widgetset = "org.vaadin.treegrid.demo.DemoWidgetSet")
    public static class Servlet extends VaadinServlet {
    }

    private static final String DEMO_SIMPLE = "Simple demo";
    private static final String DEMO_IMAGE = "Image demo";

    @Override
    protected void init(VaadinRequest request) {

        final VerticalLayout layout = new VerticalLayout();
        layout.setSpacing(true);
        layout.setMargin(true);

        TabSheet tabs = new TabSheet();

        final ComboBox combo = new ComboBox(null, Arrays.asList(DEMO_SIMPLE, DEMO_IMAGE));
        combo.setNullSelectionAllowed(false);
        combo.setSizeUndefined();
        tabs.addTab(combo, "hello");

        final TreeGrid grid = new TreeGrid();
        grid.setWidth(800, Unit.PIXELS);

        final DemoContainer container = new DemoContainer();
        grid.setContainerDataSource(container);

        grid.getColumn(DemoContainer.PROPERTY_ICON).setRenderer(new ImageRenderer());
        grid.getColumn(DemoContainer.PROPERTY_ICON).setEditable(false);
        
        grid.setSelectionMode(Grid.SelectionMode.SINGLE);
        grid.setColumnReorderingAllowed(true);
        grid.setEditorEnabled(true);

        VerticalLayout gl = new VerticalLayout();
        gl.addComponent(grid);
        
        Button b = new Button("hide last modified");
        gl.addComponent(b);
        b.addClickListener(new ClickListener() {
            @Override
            public void buttonClick(ClickEvent event) {
                Column c = grid.getColumn(DemoContainer.PROPERTY_MODIFIED);
                c.setHidden(!c.isHidden());
            }
        });
        
        tabs.addTab(gl, "world");

        combo.addValueChangeListener(new Property.ValueChangeListener() {
            @Override
            public void valueChange(Property.ValueChangeEvent event) {
                switch ((String) event.getProperty().getValue()) {
                case DEMO_IMAGE:
                    grid.getColumn(DemoContainer.PROPERTY_ICON).setHidden(false);
                    grid.setHierarchyColumn(DemoContainer.PROPERTY_ICON);
                    grid.setColumnOrder(DemoContainer.PROPERTY_ICON, DemoContainer.PROPERTY_NAME,
                            DemoContainer.PROPERTY_HOURS, DemoContainer.PROPERTY_MODIFIED);
                    setTheme("demo2");
                    break;
                case DEMO_SIMPLE:
                default:
                    grid.getColumn(DemoContainer.PROPERTY_ICON).setHidden(true);
                    grid.setHierarchyColumn(DemoContainer.PROPERTY_NAME);
                    grid.setColumnOrder(DemoContainer.PROPERTY_NAME, DemoContainer.PROPERTY_HOURS,
                            DemoContainer.PROPERTY_MODIFIED);
                    setTheme("demo");
                    break;
                }
            }
        });

        combo.select(DEMO_SIMPLE);

        layout.addComponent(tabs);
        
        setContent(layout);
    }
}

`

jrebel xml file

The released vaadin-treegrid-0.7.0.jar contains your jrebel.xml file

When hiding/unhiding columns of the TreeGrid, we get an IllegalAccessException

The treegrid tries to access the "getColumnByColumnId" method of the Grid using reflection, but this method is package visible in vaadin 7.7.9.

Method getColumnByColumnId = Grid.class.getDeclaredMethod("getColumnByColumnId", String.class); column = (Column) getColumnByColumnId.invoke(TreeGrid.this, id);

Stacktrace :
java.lang.IllegalAccessException: Class org.vaadin.treegrid.TreeGrid$1 can not access a member of class com.vaadin.ui.Grid with modifiers "" at sun.reflect.Reflection.ensureMemberAccess(Reflection.java:102) at java.lang.reflect.AccessibleObject.slowCheckMemberAccess(AccessibleObject.java:296) at java.lang.reflect.AccessibleObject.checkAccess(AccessibleObject.java:288) at java.lang.reflect.Method.invoke(Method.java:491) at org.vaadin.treegrid.TreeGrid$1.columnVisibilityChanged(TreeGrid.java:264) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at com.vaadin.server.ServerRpcManager.applyInvocation(ServerRpcManager.java:158) at com.vaadin.server.ServerRpcManager.applyInvocation(ServerRpcManager.java:119) at com.vaadin.server.communication.ServerRpcHandler.handleInvocation(ServerRpcHandler.java:437) at com.vaadin.server.communication.ServerRpcHandler.handleInvocations(ServerRpcHandler.java:402) at com.vaadin.server.communication.ServerRpcHandler.handleRpc(ServerRpcHandler.java:273) at com.vaadin.server.communication.UidlRequestHandler.synchronizedHandleRequest(UidlRequestHandler.java:90) at com.vaadin.server.SynchronizedRequestHandler.handleRequest(SynchronizedRequestHandler.java:41) at com.vaadin.server.VaadinService.handleRequest(VaadinService.java:1422) at com.vaadin.server.VaadinServlet.service(VaadinServlet.java:380) at com.datadobi.n2n.ui.vaadin.N2nServlet.service(N2nServlet.java:102) at javax.servlet.http.HttpServlet.service(HttpServlet.java:790) at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:845) at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:583) at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:224) at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1180) at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:511) at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185) at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1112) at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141) at org.eclipse.jetty.server.handler.gzip.GzipHandler.handle(GzipHandler.java:462) at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:213) at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:134) at org.eclipse.jetty.server.Server.handle(Server.java:523) at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:320) at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:251) at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:273) at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:95) at org.eclipse.jetty.io.SelectChannelEndPoint$2.run(SelectChannelEndPoint.java:93) at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.executeProduceConsume(ExecuteProduceConsume.java:303) at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.produceConsume(ExecuteProduceConsume.java:148) at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.run(ExecuteProduceConsume.java:136) at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:671) at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:589) at java.lang.Thread.run(Thread.java:748)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.