DataGridView Sort Error

0
0

If I have an empty DataGridView and I click on a header it causes an application error.

This then breaks the application.

See attached screen shot.

If I set AllowSortingDatasource to False it gets rid of the error, however the sort arrow still shows

I am using version 2.2.29.0

Attachment
  • You must to post comments
0
0

Those are different headers. The row headers is basically a column in a panel since it doesn’t scroll horizontally. The grid is composed of panes. The pane at 0 is the row headers, the pane at 1 is the scrollable columns. When you have frozen columns the scrollable pane becomes 2 and you have 3 panes, 0=row headers, 1=frozen columns, 2=the rest. Each pane has a container at the top for the column headers which contains the headers (which are widgets, like a button) on a HBox layout. If any of the widgets increases in size it makes the parent container grow to fit the widget, so it will also stretch the other widgets in the same container. Otherwise they would get truncated.

When you set the column header height, the js code will set the height to all the header containers in all the panes, but it doesn’t listen to the size changes coming from “inside”. Which probably it should…

The gdi scaling is done by the browser. Since wisej icons in our themes are all svg they will scale without losing resolution.

The sort icon is at “table-header-cell/sort-icon”. If you click on it in the ThemeBuilder it will select it and at the bottom in the status bar it will show the path to the component. It will also scroll the source code in the editor to the correct location. See attached screens, I changed the icon to 10px.

 

 

 

Attachment
  • You must to post comments
0
0

For a bound DataGridView with a combo box  column the solution for sorting is to:

  1. Add a column to the data source to hold the combo box display value which is populated using the selected value changed event
  2. Set sorting for the combo box column to be programmable
  3. Hide the display value column and set it to programmable sort.
  4. Use the Column click header event to sort the hidden column, but display the sort glyphs on the Combo box column.

This gives the illusion that you are actually sorting the combo box column

  • You must to post comments
0
0

The sorting also is not a bug. The only value in the cell is the key when the combo box has a ValueMember and a DisplayMember. The display value can change at any time. In fact winforms (attached) sorts the same way. And it’s also the same way the database would sort it since the display value is just a lookup. You can implement or change the sorting by attaching to DataGridView.SortCompare or by using Sort(IComparer).

HTH

 

 

 

 

Attachment
  • You must to post comments
0
0

Hi Frank

Thanks how do you explain the image I uploaded earlier showing that the column header height had increased when the grid contained rows, but not the height of the blank header column above the row header? I can’t understand why this is happening.

Is the gdi scaling out of sync with that required by the control?

How would I use the theme to fix this

Thanks for your help

Ewan

 

  • You must to post comments
0
0

Hi Ewan,

 

AllowSortingDatasource = false allows you to implement your own sorting if the data source doesn’t support it and you don’t want wisej to sort it for you. Showing the sort order is correct. It’s the same as SortMode.Programmatic. The sort glyph is displayed, the SortedColumn and SortOrder properties are updated, but the actual sorting is up to the program. Otherwise set it to NotSortable.

The original error you report has been fixed. It’s in the latest dev build but it turns out the dev build has other issues unrelated to this so I’d wait for the release build.

The sort glyphs as all icons in wisej scale with the browser and gdi scaling, not the control. To scale the icon you can use the theme. Otherwise a tall column header would have an impossibly scaled icon. All grids I have tried do the same

> If I sort a combo box column the key is sorted not the display data.

That’s a bug. Thanks!

 

 

 

  • You must to post comments
0
0

Hi Frank

Using 2.2.33 I notice the following:

  1. if set AllowSortingDatasource to False the sort arrows still appear which is misleading to the end user
  2.  if set AllowSortingDatasource to True the error has gone for an empty dataset – fixed
  3. If I click on the header row the appearance of the sorting arrow causes the height of header to increase but not the row header header height (when there is data in the grid)
  4. If I sort a combo box column the key is sorted not the display data.

I have set the column header height to 25 and would have expected the sort arrows to scale.

Thanks for you help

Ewan

Attachment
  • You must to post comments
0
0

Hi Ewan,

issue #2536 is fixed in our latest Wisej development build (2.2.33).

Best regards
Frank

  • You must to post comments
0
0

Hi Ewan,

We’re able to reproduce the issue, I’ve logged it as issue #2536. It should be fixed for the next build. I’ll keep you updated!

 

Best,

Levie

  • You must to post comments
0
0

Hi Ewan,

I’m having trouble reproducing the issue. Could you please attach a sample project?

Best,

Levie

  • You must to post comments
Showing 9 results
Your Answer

Please first to submit.