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

I need to convert zero values in a grid into nulls

5 Answers 179 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Ori Tidhar
Top achievements
Rank 1
Ori Tidhar asked on 30 Jun 2010, 01:55 PM
How should I do it? I'd appreciate if someone can send a code sample.

Thanks.

5 Answers, 1 is accepted

Sort by
0
Yavor Georgiev
Telerik team
answered on 30 Jun 2010, 01:59 PM
Hello Ori Tidhar,

 Could you explain your scenario in a bit more detail, please?

Best wishes,
Yavor Georgiev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Ori Tidhar
Top achievements
Rank 1
answered on 30 Jun 2010, 02:15 PM
Hi Yavor,

Sure. I'm using RadGridView to display financial data. In some of the cells the amount is zero and a "0.00" is
displayed. I would like to create a trigger or a converter which identifies this value and converts it to null.
As you know null values are not displayed in the RadGridView Cells.

See the attached image - it will clarify what I need (I want to get rid of the "0.00" values marked with yellow).
In other words - only to display the values that are greater than zero.

Thanks.
0
Yavor Georgiev
Telerik team
answered on 30 Jun 2010, 02:41 PM
Hi Ori Tidhar,

The solution is two-fold. First, your model needs to use a nullable data type. However, float, double, decimal, int, and all of the other basic data types (except string) are value types - they cannot be assign a null value to. To convert them to nullable types, we wrap them in a Nullable<> object.

Second, you need a IValueConverter that takes a value of 0 and converts it to null.

You can find the implemented solution in the attached sample application. Don't hesitate to let me know if you need any further assistance of any kind.

Kind regards,
Yavor Georgiev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Ori Tidhar
Top achievements
Rank 1
answered on 30 Jun 2010, 03:09 PM
Hi Yavor,

Thanks for the prompt reply. I have downloaded the sample project you have attached but I cant open it. It seems that you are working with newer version of visual studio - I'm using Visual Studio Team System 2008. Can you send it as earlier version?

Thanks.
0
Yavor Georgiev
Telerik team
answered on 30 Jun 2010, 03:14 PM
Hello Ori Tidhar,

 You can open the project file (.csproj) directly, instead of the .sln file. Just go to File > Open > Project/Solution... and choose Sample.csproj from the folder where you extracted the attached app.

Kind regards,
Yavor Georgiev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
GridView
Asked by
Ori Tidhar
Top achievements
Rank 1
Answers by
Yavor Georgiev
Telerik team
Ori Tidhar
Top achievements
Rank 1
Share this question
or