GridNumericColumn DataFormatString failing when loading from json ajax response

2 posts, 0 answers
  1. George Handlin
    George Handlin avatar
    5 posts
    Member since:
    Mar 2006

    Posted 15 Sep 2015 Link to this post

    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

  2. Konstantin Dikov
    Admin
    Konstantin Dikov avatar
    1793 posts

    Posted 18 Sep 2015 Link to this post

    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
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top