Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » NatTable » Nattable tree grid
Nattable tree grid [message #1053170] Thu, 02 May 2013 19:40 Go to next message
Testr t is currently offline Testr tFriend
Messages: 93
Registered: April 2013
Member
Hi,

I am trying to use Nattable grid in my application and I am able to use it with a dataprovider to show list of objects in the grid. The reason I am using a DataProvider is because all the columns that has to be shown are not the actual properties of the object and I control that in the getDataValue(col,row) method to provide the correct column data from the row object. Now that this works I am wondering if I can apply the same concept for a tree grid. My grid would have atleast couple of layers and I want to provide the data for the columns on both the layers the same way and not using the ReflectiveColumnAccessor. Is there an example that points me to do this?
Re: Nattable tree grid [message #1053209 is a reply to message #1053170] Fri, 03 May 2013 07:14 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2703
Registered: July 2012
Senior Member
Hi,

well the things you are doing with the IDataProvider can also be achieved by using the IColumnAccessor. Similar process by handling objects in a ListDataProvider. Creating an IDataProvider mostly is only useful in case you have a data model that is not relied to objects in a list, e.g. a two dimensional array or something similar.

The reason why I suggest to change your implementation to use a ListDataProvider together with an IColumnAccessor that does the work you need is, that the tree functionality in NatTable is based on GlazedLists TreeList. Therefore you need a list to implement a tree with NatTable. As the implementation of the IColumnAccessor is quite similar to implementing an IDataProvider, this should be a big deal to change.

Greez,
Dirk
Re: Nattable tree grid [message #1053290 is a reply to message #1053209] Fri, 03 May 2013 15:35 Go to previous messageGo to next message
Testr t is currently offline Testr tFriend
Messages: 93
Registered: April 2013
Member
Thanks Dirk. That seems to work. But the tree grid seems to be slower if I have more rows. I have 10000 rows with the second level for each row having 5 rows making it a total of 50000 rows. It takes atleast 5 seconds to load the grid initially. I assume the grid is virtual but the initial delay time seems to be from the TreeList.Format implementation(getPath method). This method is called for all the 50000 rows initially which is taking a while I guess. Is there any way this can be optimized?

I was wondering if we can have an implementation for the tree grid where for each row that is visible(only the rows that is shown in the view) it would query an interface that we implement to ask if the row has child rows and show the + sign and when we expand the plus sign it can further query for the child rows. This way the initial delay can be reduced. Ofcourse the sorting and filtering needs modification but I was wondering if there is an option for that customization with the tree grid.

As a side note, the normal grid does not have this hit and it shows up really fast.
Re: Nattable tree grid [message #1053303 is a reply to message #1053290] Fri, 03 May 2013 17:37 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2703
Registered: July 2012
Senior Member
Well I thought that this is the way the TreeList is working. How did you implement the Format? Or where do you think the issue is located?

Also a small example would be helpful to investigate further.
Re: Nattable tree grid [message #1053307 is a reply to message #1053303] Fri, 03 May 2013 18:32 Go to previous messageGo to next message
Testr t is currently offline Testr tFriend
Messages: 93
Registered: April 2013
Member
I implemented the TreeFormat exactly as done in the nattable example. Here is my version of the class

/*
* Class that defines the tree structure of a node by expressing the path from the element itself to the tree's root.
*/
private static class MyTreeFormat implements TreeList.Format<DataRow>
{
public MyTreeFormat( ISortModel sortModel )
{
}

/*
* Populate path with a list describing the path from a root node to this element.
* Upon returning, the list must have size >= 1, where the provided element identical to the list's last element.
* @param path //a list that the implementor shall add their path elements to via path.add(). This may be a non-empty List and it is an error to call any method other than add().
*/
public void getPath( List<DataRow> path, DataRow element )
{
path.add( element );
DataRow parent = ((DataRow) element).getParent();
while( parent != null )
{
path.add( parent );
parent = parent.getParent();
}
Collections.reverse( path );
}

/*
* Indicate whether an element can have children
*/
public boolean allowsChildren( DataRow row )
{
return true;
}

/*
* Returns the comparator used to order path elements of the specified depth.
* If enforcing order at this level is not intended, this method should return null.
*/
public Comparator<DataRow> getComparator( int depth )
{
return null;
//return new SortableTreeComparator<DataRow>( GlazedLists.beanPropertyComparator( DataRow.class, "address" ), sortModel );
}
}
Re: Nattable tree grid [message #1053311 is a reply to message #1053307] Fri, 03 May 2013 19:09 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2703
Registered: July 2012
Senior Member
Ok, why are you calling a time consuming reverse operation rather than adding parents at index 0 of the path list? Changing that could reduce your initial load time.
Re: Nattable tree grid [message #1053313 is a reply to message #1053311] Fri, 03 May 2013 19:47 Go to previous messageGo to next message
Testr t is currently offline Testr tFriend
Messages: 93
Registered: April 2013
Member
It was just carried over from the sample. But even after modifying it I see the delay. I will find out more on which method consumes more. Its actually 2-3 seconds. Also is there any memory clean up considerations that I have to do? I am using this as an eclipse plugin and when I had 5-6 views with 50000 rows I got a out of memory exception.
Re: Nattable tree grid [message #1053317 is a reply to message #1053313] Fri, 03 May 2013 20:18 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2703
Registered: July 2012
Senior Member
Well NatTable is "only" a control to show the data and does currently not support lazy loading or memory cleanup out of the box. If it is necessary for your cases you will need to implement that yourself.

We are planning to add something to NatTable that allows to get informed when cells are moving out of the viewport. But currently that doesn't exist.
Re: Nattable tree grid [message #1053324 is a reply to message #1053317] Fri, 03 May 2013 21:40 Go to previous messageGo to next message
Testr t is currently offline Testr tFriend
Messages: 93
Registered: April 2013
Member
So the lazy loading support is available in 1.0 release? So with 0.9.0 release if I have to do memory clean up how would i do it? Any example would be helpful.

Thanks for all your help. I am evaluating the grid for our plugin and so far its been great with the kind of flexibility it provides in configurations and also functionality.
Re: Nattable tree grid [message #1053343 is a reply to message #1053324] Sat, 04 May 2013 07:19 Go to previous message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2703
Registered: July 2012
Senior Member
No, 1.0.0 doesn't support lazy loading. This isn't our focus at the moment. But there are plans for improved viewport event handling that might be planned for 1.1.0.

How to do such cleanup is dependent on your data storage and your code. You could implement a timed cache for example. Unfortunately I don't have an example for that.
Previous Topic:False display of columnWidths after restore via natTable.loadState()
Next Topic:Keyboard bindings failing with latest Eclipse 4
Goto Forum:
  


Current Time: Thu Aug 22 07:54:46 GMT 2019

Powered by FUDForum. Page generated in 0.01928 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top