Locating a Datagrid Row from the Datasource Row, FAST

T

Ty

Hi all

Short version of my problem:
i have a Datagrid (Flexgrid from ComponentOne) with a Datatable as
source. I need to search a row in the datatable, using a primary key
column in the datatable, and then figure out wich row this currently
is in the Datagrid. This should probably be done using the currency
manager for speed reasons.

For the live of me, i can't figure out how to locate the row very fast
in the Datagrid. Everybody is just talking about finding a record in
the datatable corresponding to a row on the datagrid, so the other way
arround.


Some explanations:
Speed is a primary concern. This Datagrid is very dynamic. It can
contain several thousand records (worst case) and several 100 updates
or even 1000 updates a second can trickle in. Those updates need to be
visualized with colors on the grid. The amount of records in the grid
can change very often. also, the user can sort the 2 douzen or so
columns.

Simply scanning thru the grid (using Search function of the grid),
searching for the right key is no option because only about 50 records/
sec can be located like this.

The only solution i have right now is filling a Hashtable with Key and
Datagrid RowID every time the amount of records in the grid change or
the user changes sorting. Then using the Hashtable to locate the row.
About 30000 rows a second can be located like this. Fast enough. But
it's not very elegant and error prone. And it's possible that changes
on the grid happen very often, negating the speed advantage of the
Hashtable.

I found out, that locating a record on the Datatable is just as fast
as in Hashtable, 30000recs/s (in a 5000recs Datatable). Also, if i
change some cell/col value in the Datatable, this change is immediatly
shown in the grid, no matter how the grid is sorted. Locating and
changing a value can be done almost 20000 times a second. Hence, there
IS a way to locate the row in the grid very fast. probably using
currency manager.


It would be great if someone could help me. Thanks for any hints!

Greets

Beat
 
T

Ty

Hi

no, first i need to locate the record in the datatable, then change
some values in some columns (wich then automatically changes the
values in the datagrid). then i change the background-color of the row
or the cell in the grid, to indicate the change for the user. the user
always sees all the current records.


what i'm really looking for is how to get directly from datatable row
to datagrid row. this must be stored somewhere, since the grid updates
correctly and very fast when i make updates in the datatable, no
matter how the grid is sorted or even filtered. this must somehow be
done using the currency manager. i think it would be a very simple and
fast solution, if i could only find it...


i've tried using the DefaultView of the Datatable, sorted by the Key,
this works, but only as long as the user doesn't sort by some other
field.


in my desperation i even called up Microsoft asking for technical
support. The only support they have is opening a troubleticket and
paying 480$ up front. and then you don't know, when the problem will
be solved...

if someone knows a really good support hotline or chat for .net, let
me know too.

so, pleeaaaze help :)
 
I

Ignacio Machin ( .NET/ C# MVP )

Hi all

Short version of my problem:
i have a Datagrid (Flexgrid from ComponentOne) with a Datatable as
source. I need to search a row in the datatable, using a primary key
column in the datatable, and then figure out wich row this currently
is in the Datagrid. This should probably be done using the currency
manager for speed reasons.

Well, 30k of rows is a HUGE amount, you should only load thoe you are
going to show, I recommend you to use some paging in the server.

Also you should first post in the forums of the grid you are using,
maybe there is a faster, or recommended way of doing this.
 
T

Ty

Hi,

it's not 30000 records. i'm testing the worst case wich MAY be 5000
records. using hashtable or datatable can locate 30000 records each
second in a 5000 records table. usual would be a couple hundert
records in the grid/table and a couple hundert searches/updates per
second. it depends on the user. and it's a windows application and not
a web application.

the whole application (potentially a douzen forms on screen,
distributed on several screens) is very performance critical. data has
to be shown in realtime on different forms and comes in streaming from
a dataprovider. so even if the slower methods would do for 99% of the
cases in this form, i need to spare cpu ressources where ever i can
for other interactive forms. slow execution=lot of cpu time.

i did check on the forum of the grid. there are 2 or 3 questions
exactly for this but no satisfying answer. one possible solution was
to fill a hashtable with key and gridrow index (was nice to see that i
wasn't that far off with my hashtable solution :)). but it's not
really efficient since i would have to change the hashtable with every
change of sort or amount of records in the datagrid/datatable.

it's also about having a clean solution, going the shortest way
possible. the rowindex information must be directly available,
somewhere, since data updates are very fast in the datagrid when
changes on the underlying datatable are made. i don't like going the
"ah well, it's working" route when i know/suspect that there is a
faster, cleaner, more logical and ultimately easier to maintain way
to do it.


Thanks

Beat
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top