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

GridNumericColumn DataFormatString failing when loading from json ajax response

1 Answer 88 Views
Grid
This is a migrated thread and some comments may be shown as answers.
George Handlin
Top achievements
Rank 1
George Handlin asked on 15 Sep 2015, 03:53 PM

I have a grid that is being loaded based on search criteria that calls into a generic http handler that returns json. The grid loads perfectly fine this way, however a couple of the fields are numeric and using this format string  DataFormatString="{0:#,##0.00}" is failing.

 Here is column declaration:

<telerik:GridNumericColumn UniqueName="ExtendedCost" HeaderText="Extended Cost" DataField="ExtendedCost" AllowSorting="True"  DataType="System.Decimal" DataFormatString="{0:#,##0.00}"></telerik:GridNumericColumn>​

 This format string works fine with a grid that is loaded in code-behind.

 Here is the json that fills the grid.

[{"SystemId":20567,"Descriptor":"Hot Water Tank","AssetId":1352,"AssetName":"Asset 15","CampusId":224,"Campus":"Campus 12","InstallYear":2001,"DesignLife":15,"Velr":null,"AssignYear":2017,"EndOfLife":2016,"Beyond":-1,"Level4Code":"D3015","Level4Title":"Hot Water Supply System","SystemCostStatusId":3,"OperationStatusId":1,"MasterFormatId":"00020567","ProjectName":null,"Snoozed":false,"UniformatId":143,"UnitCost":500.00,"ExtendedCost":1045.00,"Location":null,"Sublocation":null,"FloorId":null,"RoomLocation":"To Be Determined","RoomTypeId":4,"Manufacturer":null,"Notes":null},{"SystemId":355997,"Descriptor":"Hot Water Tank","AssetId":23564,"AssetName":"Asset 15","CampusId":1314,"Campus":"Campus 242","InstallYear":2001,"DesignLife":15,"Velr":null,"AssignYear":2017,"EndOfLife":2016,"Beyond":-1,"Level4Code":"D3015","Level4Title":"Hot Water Supply System","SystemCostStatusId":3,"OperationStatusId":1,"MasterFormatId":"00020567","ProjectName":null,"Snoozed":false,"UniformatId":143,"UnitCost":500.00,"ExtendedCost":1677.50,"Location":null,"Sublocation":null,"FloorId":null,"RoomLocation":"To Be Determined","RoomTypeId":4,"Manufacturer":null,"Notes":null},{"SystemId":361433,"Descriptor":"Hot Water Tank","AssetId":23656,"AssetName":"Asset 72","CampusId":1319,"Campus":"Campus 247","InstallYear":2001,"DesignLife":15,"Velr":null,"AssignYear":2017,"EndOfLife":2016,"Beyond":-1,"Level4Code":"D3015","Level4Title":"Hot Water Supply System","SystemCostStatusId":1,"OperationStatusId":1,"MasterFormatId":"00020567","ProjectName":null,"Snoozed":false,"UniformatId":143,"UnitCost":500.00,"ExtendedCost":1677.50,"Location":null,"Sublocation":null,"FloorId":null,"RoomLocation":"To Be Determined","RoomTypeId":4,"Manufacturer":null,"Notes":null}]

 

Thank you

1 Answer, 1 is accepted

Sort by
0
Konstantin Dikov
Telerik team
answered on 18 Sep 2015, 12:49 PM
Hi George,

With client-side binding, such DataFormatString is not supported, because RadGrid is calling internally the toLocalString method at some point, which is the reason for that limitation. With that in mind, I would suggest that you use the following format instead, where you could specify the decimal digits:
DataFormatString="{0:n2}"

Hope this helps.


Regards,
Konstantin Dikov
Telerik
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 Feedback Portal and vote to affect the priority of the items
Tags
Grid
Asked by
George Handlin
Top achievements
Rank 1
Answers by
Konstantin Dikov
Telerik team
Share this question
or