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

Implementing a custom IFormatProvider for RadGrid

1 Answer 73 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Lance
Top achievements
Rank 1
Lance asked on 03 Jun 2010, 04:44 AM
Hello,
I have a situation where I need to format decimal numbers in a grid to Feet and Inches.  ie: 2.5 = 2' 6" I have an extension written to the decimal type that takes care of this, and it works fine.  However, now we are getting into wanting to sort, and sum, etc.. I implemented custom aggregates that work fine, but the code is getting more and more convoluted.  I am taking a step back, and it seems that if I could just implement a custom IFormatProvider and use the formatting within the grid control DataFormatString that all my problems would go away.  I was thinking something like DataFormatString="fi{0}" and within my format provider, I could check that it starts with "fi" and format it the correct way. 

Is this even possible, or am I barking up the wrong tree?

Thanks
Lance

1 Answer, 1 is accepted

Sort by
0
Yavor
Telerik team
answered on 08 Jun 2010, 08:23 AM
Hi Lance,

One possible option which you can consider is dynamically altering the data. This may be similar to the approach demonstrated in this article:

http://www.netomatix.com/development/gridviewcustomdataformatting.aspx

The same logic is applicable to the grid control - the corresponding event is the ItemDataBound.
I hope this information helps.

Sincerely yours,
Yavor
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
Grid
Asked by
Lance
Top achievements
Rank 1
Answers by
Yavor
Telerik team
Share this question
or