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

GridNumericColumn format

5 Answers 664 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Christopher Borys
Top achievements
Rank 1
Christopher Borys asked on 21 Jan 2010, 01:07 AM
I think there is a bug regarding GridNumericColumn and formatting.  I use currency format as follows: {0:#,##0;(#,##0);0} .
In the view mode column looks OK.  The problem is when the row/item is in edit mode and yet the column is readonly.
If the column is readonly, I should see the same formatting as in the view mode.  Is this a bug?

I see a lot of threads on the same topic and yet could not find definite answer from TELERIK on the topic.
Is there a manual fix?

Chris

5 Answers, 1 is accepted

Sort by
0
Martin
Telerik team
answered on 25 Jan 2010, 03:51 PM
Hello Chris,

I am not quite sure that I completely understand the meaning of the string format that you use. So could you please share the code snippets (markup and logic if any) used to setup your GridNumericColumn? Additionally would you mind providing us with the links to the forum posts you mentioned?

Regards,
Martin
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Christopher Borys
Top achievements
Rank 1
answered on 08 Feb 2010, 04:07 PM
1. The formatting string does not shows digits after decimal point and the negative numbers are shown in parenthesis.
 I really don't thisn that the formatting string has nanything to do with it.  You can use a different one as long as you will see distictively the difference between internal number and the displayed one.
    a) make item editable
    b) make the column read only and see if the number is displayed properly


2.  My column is defined as follows:

 

<telerik:GridNumericColumn DataField="AmountPayorFC" UniqueName="AmountPayorFC" HeaderText="Dividend Paid<br>(FC - Payor)" ReadOnly="True"

 

 

HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Right" DataType="System.Decimal"

 

 

ItemStyle-CssClass="numeric" HeaderStyle-Width="100px" DataFormatString="{0:#,##0;(#,##0);0}">

 

 

</telerik:GridNumericColumn>

 


0
Martin
Telerik team
answered on 10 Feb 2010, 03:55 PM
Hello Christopher Borys,

I was able to reproduce the reported behavior only when the grid uses "InPlace" edit mode. This is due to the fact that when an item is in edit mode the data item displays the value from the relevant column editor. This value is hold not formatted because when "update" command is triggered it will be extracted from the column editor and will be passed back to the data source. If the value is formatted it might not match the data type of the field and the update operation will fail.

When the mode is different than "InPlace", RadGrid creates the column editor in a different item. This makes possible to keep the data item cell value formatted while the column editor holds value that is not formatted. If the column is "readOnly" then the editor is not displayed and all you see is the formatted value from the data item cell.

I hope this helps,
Martin
the Telerik team

Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Follow the status of features or bugs in PITS and vote for them to affect their priority.
0
Sujata
Top achievements
Rank 1
answered on 04 Jan 2011, 07:44 AM
negative numbers are shown in parenthesis but i want to change its forecolor to red on client side .
not on server side rowdatabound event .


0
Princy
Top achievements
Rank 2
answered on 04 Jan 2011, 10:21 AM
Hello Sujata,

The following code snippet shows how to change the forecolor of grid column from client side.

ASPX:
<telerik:GridNumericColumn DataField="AmountPayorFC" UniqueName="AmountPayorFC"
     DataType="System.Decimal"  DataFormatString="{0:#,##0;(#,##0);0}">
 </telerik:GridNumericColumn>

<ClientSettings>
    <ClientEvents OnRowCreated="OnRowCreated" />
</ClientSettings>

Java Script:
<script type="text/javascript">
    function OnRowCreated(sender, args) {
        args.get_gridDataItem().get_cell()("AmountPayorFC").style.color = "red";
    }
</script>

Thanks,
Princy.
Tags
Grid
Asked by
Christopher Borys
Top achievements
Rank 1
Answers by
Martin
Telerik team
Christopher Borys
Top achievements
Rank 1
Sujata
Top achievements
Rank 1
Princy
Top achievements
Rank 2
Share this question
or