When i create group by on Ultragrid using a column e.g. 'Sector' its created with multiple groups of "None" when the values are null.
The desired behavior should be only one group of "None" and not multiple groups of "None"
Please advice.
I want to make sure I'm following you with the question...
You have an UltraGrid and when you have a column with null values and perform a GroupBy on that column, you see multiple GroupBy Rows for the nulls instead of one GroupBy Row for all the null values?
I see one as shown in the image below:
There are 507 items in Northwind database with null ShipRegion values. What are you seeing?
I see multiple groupings of Null when the value is blank. Ideally it should show only one group of "None".
See the attached file
gsadamastula said:still curious why there were more than 10 grouping when there should be 2 ( based on null , blank)
Probably because null and blank are sorted in an arbitrary order.
The way grouping works is that the grid first sorts the grouped column. Then it goes through rows in order and matches up groups. So the sort order probably ended up with a random order for blank and null.
So, for example, you could have:
blank
null
In a case like that, you would end up with 4 group by rows:
blank (2)
null (1)
blank (1)
null (2)
gsadamastula said: I overrided the values to "" when the values are Null,Blank and that solved the problem for now. Is this the correct way to do it?
I overrided the values to "" when the values are Null,Blank and that solved the problem for now.
Is this the correct way to do it?
You can do that if you don't mind altering your data. It might not be a bad idea to be consistent with blanks and nulls, anyway.
Another option would be to assign a GroupByEvaluator class to the column. You would just have to implement the IGroupByComparer interface. It's a pretty simple interface with only a single method and it would allow you to tell the column to treat blank and null as the same.
I figured out that the column has Null, Blank values and that's why there are multiple groupings. still curious why there were more than 10 grouping when there should be 2 ( based on null , blank)
What's the data type of the column here? My guess is that the grid is comparing the values in the cells and the Equals method is returning false for some reason. Maybe you are using a custom object of some kind for this column and overriding the Equals method?
Something else is going on here as that would defeat the purpose of grouping. I am forwarding this over to our Developer Support to help investigate why your grid is not grouping correctly.