Large dataset and winforms - winforms

I have a dataset which is about 3 million records, and I would like to load them in to a Data Grid within an application (WinForm).
What is the best approach / method of displaying the data.
I need to be able to run a filter to the data to reduce down the data set, ideas would be welcomed

A good idea would be filtering the data in the database and retrieving only the (pre)filtered result set. If this set is still large, use virtual mode, but also rethink your design - if you want to display so much data, that you are getting into performance problems, you might be showing to much data for a user, too.

In addition to filtering you should also consider paging in the backend (your SP should handle paging)

You can bind the grid to the DataSet, using the DataSource property and a BindingSource component. The Forms designer can take care of the creation of the BindingSource for you.
The BindingSource has a Filter property that allows you to filter the content of the DataSet
EDIT: by the way, in data-bound mode, the DataGridView implicitly uses virtual mode, so you don't have to worry about having too many rows in the grid

Related

Loading 35000 rows from DB using linq make WPF page loading slow

Scenario:
I have a TelerikAutoComplete control in one of my WPF page and the item source is a property which is filled from 35000 rows from a table in DB.
Issue :
It takes longer to retrieve the data which is hampering the load of the page.
Resolution Tried:
[EDITED]
Cause of issue was different which has been defined in answer below.
Let me know in case you need more information.
Thanks in advance.
What about: Do not load 35000 rows. That is not a sane UI if it needs all pages loaded. So, use virtualization.
I tried using the background worker, since that also derived by
dispatcher thread it still hold the page until the data is filled up
in the property.
Ah, no. Back to documentation becasue quite obviously you are not using it correctly.
The reason behind this delay was the database. We had this data coming from view which was taking whole lot of time. Changed this view into table and it made processing really quick..Sorry for late answer.

is data binding instead of loading data table in my own code a bad practice for a readonly data grid view?

I am using DevExpress GridView here, but I am guessing that the issue is relevant more broadly, at least in the WinForms world of data-driven apps.
At present I am usually doing data binding when displaying data freshly loaded from database and this is also a common practice in the code base I inherited. But, often enough I am unable to format (alter the text) the bound data using format strings, so I end up having to hide the poorly formatted columns, add unbound columns with similar names and dynamically populate them with formatted data from the hidden ones (the previous programmer did even worse, he routinely formatted inside stored procedures, ugh!). I get the nagging feeling that maybe this approach just sucks.
So I am thinking about an alternative - suppose I create my own FormattableGridView especially for the purpose of displaying readonly data. All columns will be unbound and populated dynamically from the data table, while preserving the same column names as the data table itself. If I want to format some columns, some rows or in a zig-zag fashion through the grid, I just do it directly dynamically, because the unbound grid can be messed with just as easily as a 2-dimensional array.
This might sound nice and good, but apparently data binding of grid views (most of which presumably are also readonly) is a pretty common thing. I find it mentioned online all the time. So, are there drawbacks that I am ignorant of to the pattern I delineated above that keep it from spreading? Or is the data binding in itself an unwise pattern in these cases whereas what I described is indeed the better way?
EDITED:
ok, so in part answering my own question, further research uncovers DevExpress CustomColumnDisplayText event apparently specifically intended for unrestricted formatting of databound grids. Perhaps similar events exist in gridview components from other similar frameworks. Ok, so maybe that indeed is the proper pattern, although the event-driven way of handling this issue feels a bit weird.
The grid publishes the GridView.CustomColumnDisplayText event which can be used to format wrongly formatted values. I think, that this is the best and easiest solution for this task.

Binding WPF control to multiple sources (not traditional multibinding)

I am trying to do some databinding magic. I have a Shipments view that lists shipments, and provides filtering and ordering ability on the list. The filter string box, Delivery Status filters (checkboxes) and Ordering Radiobuttons are databound to properties in the ViewModel. I want to add the ability to save state and I have elected to do this by saving control states in an xml document. Previously I have done this before with little problem, using databinding to just read/write the values back and forth.
However, now I have a quandry. My filter controls are currently databound to items in the ViewModel. i can write code that changes their databinding from the xml to the ViewModel on load and vice versa, but that would be messy.
Is there a mechanism in place that I can use to achieve the ability to bind to two equal sources and have them updated at the same time?
This sounds like a concern for the view model.
Why not load the saved values into the view model, and have the view model decide what data to expose?
Then the view doesn't have to be concerned with managing data.
None that I'm aware of.
My opinion: I really wouldn't do this anyway - if your datacontext is the viewmodel, and the viewmodel has properties for the filter, you almost certainly should be persisting and retrieving the relevant viewmodel state to keep the state of the filters. Trying to save controlstate, then retrieve it, set it, and set the viewmodel based on the new controlstate sounds like a lot more work and much more prone to bugs.

Sorting Data using Silver light Data Grid control

I have a grid control in silverlight.I set up pagination for this control.Data is populated from db.I am trying to a sorting on all column headers.However sorting gets applied to specific page and does not apply to entire result set.How can this issue be fixed? Any suggesstions would be of great help.
Regards,
Pri
You can provide explicit IComparer implementations for the columns, as well as event handlers, to handle both questions.
Handle the click event on the header to resort your data however you like.
http://www.longhorncorner.com/UploadFile/nipuntomar/SortingDataSilverlightDataGrid09152008025951AM/SortingDataSilverlightDataGrid.aspx
And leverage the ICollectionView IComparer implementation to do the sorting of the HyperLinks
http://msdn.microsoft.com/en-us/library/system.windows.data.listcollectionview.aspx
(is the text of the hyperlinks all the same, e.g. ClickMe ?)
Also - since Silverlight is running on the client, has all the data been brought to it (or just that page's data, and paging is bringing data to the client)? eg what data source are you using? RIA Services and DomainDataSource? Or your own service calls?)
You might want to use PagedCollectionView. PagedCollectionView gives you lot of functionality out of the box without writing much code.You can use it to sort the data,filter the data,group the data.
Get your data from server in the way you prefer and create a PagedCollectionView with the object collection retrieved from the server and bind the datagrid with PagedCollectionView.
You can sort the data by adding SortDescriptions.
It is explained with examples at MSDN. Especially look for sort section.
Hope this helps.

Extjs Combobox using json

What is the max size for combobox using json? I seem to die at 5000 json elements.
To state the obvious, from a usability standpoint rendering thousands of records into any UI component is completely useless. No human will be able to make use of that much data. A better approach would be server-side filtering to fetch a usable subset of the data. The combo also supports remote paging if that's an option for you -- there's an example of that in the Ext samples. There's no "built-in" limit to the amount of data that the combo can handle, but there are practical limits to how much data/rendering any page can handle and still be responsive.

Resources