StrataFrame Forum

EnhancedList filtering does not work correct with non-string types.

http://forum.strataframe.net/Topic14339.aspx

By George Nentidis - 2/12/2008

Hi.

I am using an EnhancedList to display the contents of a BO.

When trying to sort the columns in the grid, sorting does not work correctly for numeric columns. Also when enabling filtering, filter conditions like <, >, <=, >= do not work correct either with numeric columns. It looks like the EnanhancedList makes all columns of type string.

Is there a way to overcome this so that filtering works ok?

Thank you

By StrataFrame Team - 2/13/2008

Does it sort the numeric columns at all, does the sorting operate incorrectly... like 1 and 11 come before 2 and 3?
By George Nentidis - 2/13/2008

The following column displays balances. It is sorted as you can see (by the little arrow in the column header), and also filtered to display all values bigger than 100 euros.

This is an EnhcanedList bound to a Customer BO.

By George Nentidis - 2/13/2008

Let me know if you might need a sample application, to help you with that...
By Trent L. Taylor - 2/13/2008

A sample always helps and speeds up the process can we can just run it to get to the crux of the issue.  For whatever it is worth, we don't actually do anything on the sort.  The EnhancedList is just an XtraGrid that acts more like a listview than a grid.  So this sorting logic isn't actually something that we implemented....this should be the basic grid functionality.  Now there could be something coming over into the grid as a different type or something of that nature which may be causing the issue, so I would like to look at a sample so that we can at least determine where the issue is manifesting itself.
By George Nentidis - 2/25/2008

Trend, here's a sample.

It is a small BO with only three properties and the DB it uses. The DB contains a single table, with only those three columns. Balance is a money property.

Run the application and try to sort by the Balance field. The sort does not really work as it should be. Also if you enable filtering, try to show all rows with Balance bigger than 10. You will get -10 also. The DisplayFormat of the columns is set to Numeric but that doesn't seem to work. I think that somewhere along loading of the grid, the column looses its data type and it is turned to a string. Perhaps you during formatting of the column.

I hope this will help you find the cause.

Thank you...

By Trent L. Taylor - 2/25/2008

Actually, before I even look at the sample, you are correct in a point that you made.  All data is ultimately turned into a string.  Just as the combos and standard SF ListView work, so does the EnhancedListView.  When the columns  are created, they are created using the String.Format command.  This logic is not going to change, and that is why I recommended using a grid (to you or another user) the other day regarding this type of data.  The EnhancedList was created ONLY to emulate the functionality of a ListView.

One thing you can do though, is sort the BO before you populate the list instead of relying the grid to sort the columns.  So before you call the Requery method on the list, set the sort of the BO and then load.  You can populate a BO on the form or user control, then within the List, use the CopyDataFrom method.  Then in the ListPopulating event of the EnhancedList, pass the BO that is populated and sorted.  This will then load the list as you would like.