Most developers have encountered a need at some point to modify how data is displayed to the user. The RadGridView offers a very straightforward way to format data without having to modify the source data. For example, you may not want the time displayed with a DateTime field, or you want to change the structure of the data to meet an internal standard. The screenshot below shows three different fields which display the default DateTime format.
This may be valid data, but it may not be useful to the user and we could potentially save screen real estate by eliminating unnecessary information. By using the FormatString property of the column you can apply the same standard formatting options available with the string.Format method.
The code shown will apply different custom formatting options, as seen below. The time data is no longer visible since we are specifically concerned with the date.
Formatting can is particularly useful when dealing with numeric data since it can represent currency, percentages and so on. Look at the Order Details table information below. The values are informative, but you could not know that 14.0000 is a dollar amount necessarily unless you looked at the column header.
By applying formatting we can make it much more readable for the user and give the visual hint of the type of information the user is looking at.
The code above using the same formatting technique will allow the data to be represented more accurately.
The simplicity of this feature makes it something you can implement with your existing or new applications quickly. To assist you in getting started I have outlined some handy references for the formatting options available.
DateTime Format Options http://msdn.microsoft.com/en-us/library/system.globalization.datetimeformatinfo.aspx
Number Format Options http://msdn.microsoft.com/en-us/library/system.globalization.numberformatinfo.aspx
Nikolay Diyanov is the Product Manager of Telerik's UI for iOS and UI for Xamarin divisions. He joined the company back in 2007 as a Support Officer and made his way up the ladder over the past few years. Delivering outstanding solutions that make developers lives easier is his passion and the biggest reward in his work. In his spare time, Nikolay enjoys travelling around the world, hiking, sun-bathing and kite-surfing.
Find him on Twitter @n_diyanov or on LinkedIn.
Copyright © 2016, Progress Software Corporation and/or its subsidiaries or affiliates. All Rights Reserved.
Progress, Telerik, and certain product names used herein are trademarks or registered trademarks of Progress Software Corporation and/or one of its subsidiaries or affiliates in the U.S. and/or other countries. See Trademarks or appropriate markings.