Current filter:
                                You should refresh the page.
                                0
                                  • Hello!

                                    I have a GridView which has a number of columns bound to several numeric properties (ints, doubles, or so). In my business object I use the extremal number "-1" to represent a "null" value in these numeric properties. That means that if the value is -1, then the property is unknown, not set.

                                    How could I force my columns to treat -1 values as Null values? I need the filter mode set to Value, and SortMode set to Default as well, to let users useing the numeric specific capabilities. I use CustomDisplayText event for replacing -1 values with empty strings, however I still see the -1 in the filter popup for example, and also sorting takes -1 as it is, instead of null.

                                    Thank you,

                                    Zoltán

                                You must  log in  or  register  to leave comments

                                2 Solutions

                                Creation Date
                                Rating
                                Importance
                                Sort by
                                0

                                In these situations using a nullable type seems to be a good solution, instead of using not nullable type and a special value to represent "null".

                                • I agree with you that the use of a nullable type is the most appropriate solution here. If it is impossible to change the type of the required field, you can use unbound columns, as I suggested above.

                                You must  log in  or  register  to leave comments
                                0

                                The only correct way here is to use unbound columns. I have created a small sample to illustrate this.

                                I hope this information will be helpful to you.

                                dxSample.zip
                                • Hello Gosha, sorry for the late reply.
                                  Unfortunately using unbound columns is not an acceptable solution in my real project, because I have several grids with a lot of such numeric columns. I'm completely stuch with this (I think not so uncommon) problem. See also my other post at http://www.devexpress.com/Support/Center/Question/Details/Q414847 for further clarification of my problem.
                                  Thank you!

                                • Just now I got an idea. Wouldn't it solve all my problems if I used "double?" instead of "double" for my underlying property? Can a GridView work with nullable types property? I mean sorting and filtering by value.

                                • I've tested "double?" instead of using -1, and it looks fine.

                                You must  log in  or  register  to leave comments
                                You must  log in  or  register  to leave an answer

                                Is your intention to post an answer to your own question?

                                • If so, then proceed.
                                • If you simply wanted to post additional information, ask for further clarification, or to just say "Thanks!", please click Leave a Comment.
                                • If you wish to edit your original question, please use the Edit button in the Toolbox at the top right corner of that entry.