|swt table itemcount doubt [message #876266]
||Thu, 24 May 2012 09:18
| RaaZ Siripuram
Registered: April 2012
I have been stuck with one issue. Could anyone help me to get out of this.
I have created one AsyncronousTableViewer. First column of the table represents its row id (increments by 1) and it is primary key. In my data base I have millions of rows. Cache contains fixed number of rows (in my case 1000) and it has set to be as input to viewer.
As user scrolls down, cache will be updated (by giving query to database) with next 1000 rows and set this cache as input to viewer.
I want scroll bar thumb position should represent table data position in the database data.
More clearly, suppose, in database I have 10,000 records and in my table view has 5000 to 6000 rows (1000 rows), then thumb position should be at 50%. Same way if table got 8000 to 9000 rows(table always contains 1000 rows), then thumb position should be at 80%.
For this, for each event, I used verticalBar.setSelection(selection);
But, this raises many issues
please find here stackoverflow.com/questions/10315991/set-vertical-bar-thumb-position-programmatically
Later I realized that, it would be better to set total records in database as table item count.
So I set 10,000(above assumption) as item count.
Then table contains 0 - 9999 rows. Among them only 1000 rows(cache data) contain actual data to be displayed in the table view.
But when I set 5000 to 6000 rows as viewer input, these 1000 rows are placing in the table at 0-999 indexes. So again thumb position is at 0%.
How can I manage these thousand rows at 5000-5999 indexes of table rows.Then only thumb position will be at 50%(that is my expected position).
Hope you got my point.
Could you please help me to get out of this issue.
Is my approach is correct or is there any other way?
Any suggestions would be appreciated...
|Re: swt table itemcount doubt [message #878690 is a reply to message #876985]
||Tue, 29 May 2012 18:30
| Grant Gayed
Registered: July 2009
The point of Tables with style SWT.VIRTUAL is to enable you to create a |
Table with an arbitrary item count (millions are fine in theory, though
this does not make for a good UX). The question is, how many items
should your Table contain, regardless of the size of your database, or
your caching strategy? Just set this as its item count and it will ask
you for the items lazily as they're needed (needed == in the user's
viewport). Whether you answer these items with values taken directly
from the database or from some cached records that you've previously
retrieved is a detail of your implementation. Attempting to play with
the Table's scrollbar will not work; if you want to change the number of
items in the Table then just invoke setItemCount() again with the new value.
- basic SWT.VIRTUAL Table example:
- SWT.VIRTUAL Table example that demonstrates populating 64 items at a
time, as if retrieved en masse from a database:
On 5/25/2012 12:23 PM, RaaZ Siripuram wrote:
> Thanks Mario for your contribution.
> Of course, I used VIRTUAL style.This is different case.
> I have to manipulate billions of rows from database. Thats why I used
> Actual problem is with thumb position(first half of the above post).
> Is there any other way to fix that issue.
> From database(among millions of rows) view gets only 1000 rows.
> But I need to set thumb position based on at what % of data (from
> database) view filled with.
>>>> I want scroll bar thumb position should represent table data
>>>> position in the database data.
>>>> More clearly, suppose, in database I have 10,000 records and in my
>>>> table view has 5000 to 6000 rows (1000 rows), then thumb position
>>>> should be at 50%. Same way if table got 8000 to 9000 rows(table
>>>> always contains 1000 rows), then thumb position should be at 80%.
> Hope you get for what I am trying.... :roll:
> Programatically I set thumb position at my desired place.But OS itself
> tries to replace thumb at actual position.
Powered by FUDForum
. Page generated in 0.02101 seconds