This is a migrated thread and some comments may be shown as answers.

Grouping fails when not data for some columns

1 Answer 48 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Matt
Top achievements
Rank 2
Matt asked on 29 Dec 2012, 02:26 AM
That title should read "Grouping fails for nullable columns when no data rows are present in the grid"

When the grid has data in it, all columns group and ungroup normally by dragging them to the group bar.
If the grid has no data rows, only a header is showing, then only non-nullable columns (DateTime in my case) can dragged to the group bar and all the others show a red circle with a line through it as you drag them over the bar.

Same is true for sorting. If you click on a nullable column with no data rows, sort indicator does not change. Non-nullable (DateTime) do.
Also, the nullable columns, when no data rows are present, have no filter icon. Non-nullable (DateTime) do.

Has anyone else noticed this? Is there any solution or is this a bug in the grid?

I code behind generate all the columns of the grid, and everything works perfectly if the grid has data rows. It could be the generation, but the code behind is fairly straightforward and again works fine with data.

I have attached a picture of the filter absence/presence. The types are easily identifiable.

Any input would be appreciated.

1 Answer, 1 is accepted

Sort by
0
Matt
Top achievements
Rank 2
answered on 29 Dec 2012, 02:51 AM
Never mind, I answered my own question. I realized while creating a demo project that the type would not actually be known until data is bound, i.e. once a row is applied and data type of the column would be known, without using the "DataType" property of the column object in column generation; which I was not doing. Once I applied the correct type to the property, all fields bounced back to life without issue with no data in the grid; except for the image which I would never want to group or sort by and expect that behavior.

I'm still not sure why DateTime fields work without the data type specifically mentioned. There must have been some other property that was providing a clue prior to binding.
Tags
GridView
Asked by
Matt
Top achievements
Rank 2
Answers by
Matt
Top achievements
Rank 2
Share this question
or