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

DecimalSeparator, GroupSeparator properties for GridNumericColumn

7 Answers 431 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Asp Net
Top achievements
Rank 1
Asp Net asked on 24 Sep 2011, 02:42 PM
Hi,

RadNumericTextBox controls contains DecimalSeparator and GroupSeparator properties in NumberFormateSettings collection. But these properties are not available in RadGrid's GridNumericColumn. Unfortunately GridNumericColumn's DataFormatString property also not working correctly. How can I achieve these properties behaviour in GridNumericColumn? (Even I'm ready to develop CustomRadGrid control also.)

7 Answers, 1 is accepted

Sort by
0
Jayesh Goyani
Top achievements
Rank 2
answered on 24 Sep 2011, 03:49 PM
Hello,

please check below code snippet for set such type of property.
<telerik:GridNumericColumn DataField="ID" HeaderText="ID" UniqueName="ID"></telerik:GridNumericColumn>
protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
        {
            if (e.Item.IsInEditMode && e.Item is GridEditableItem)
            {
                GridEditableItem item = e.Item as GridEditableItem;
                RadNumericTextBox RadNumericTextBox1 = item["ID"].Controls[0] as RadNumericTextBox;
                // set your property here
            }
        }

Let me know if any concern.

Thanks,
Jayesh Goyani
0
Asp Net
Top achievements
Rank 1
answered on 24 Sep 2011, 04:58 PM
Hi Jayesh Goyani,

Thanks for your reply. Actually my grid is not in edit mode (its in display mode only). And also I'm not using RadNumericTextBox inside the grid. I'm only using GridBoundColumn and GridNumericColumn columns.
RadGrid1 is like this

 

<telerik:RadGrid ID="RadGrid1" runat="server" Width="100%" AutoGenerateColumns="false" 
  
AllowFilteringByColumn="true" AllowSorting="true" AllowPaging="true" PageSize="3"
<MasterTableView DataKeyNames="Id" TableLayout="Fixed"
<Columns
<telerik:GridBoundColumn DataField="Id" HeaderText="Id" Resizable="false" UniqueName="Guid" Visible="true"> 
<telerik:GridNumericColumn DataField="Salary" HeaderText="Salary" Resizable="false" UniqueName="Salary" Visible="true"> 
</telerik:GridNumericColumn></Columns></MasterTableView></telerik:RadGrid

 



On the above Numeric Column I want to apply DecimalSeperator and GroupSeperator functionalities.

If I able to achieve above functionality then I will expose these two properties in my Custom Grid and that functionality I will incorporate in customRadGrid itself (we require same functionality in many places thats why making CustomRadGrid.) And all my control users just set these two properties as per their need like below
<mytelerik:myRadGrid ID="myRadGrid1" runat="server" Width="100%" AutoGenerateColumns="false" 
AllowFilteringByColumn="true" AllowSorting="true" AllowPaging="true" PageSize="3">  
<MasterTableView DataKeyNames="Id" TableLayout="Fixed"
<Columns
<mytelerik:myGridBoundColumn DataField="Id" HeaderText="Id" Resizable="false" UniqueName="Guid" 
Visible="true">
<mytelerik:myGridNumericColumn DecimalSeparator="," GroupSeparator=" "  DataField="Salary" HeaderText="Salary" Resizable="false"  UniqueName="Salary" Visible="true">     
</mytelerik:myGridNumericColumn
</Columns>  
</MasterTableView>  
</mytelerik:myRadGrid>

 

Any way this CustomGrid is secondary, first of all I'm unable to achieve Decimalseparator and GroupSeparator functionality on GridNumericColumn (in display mode only not in edit mode). Any suggestions are appreciated.

 

0
Kavitha
Top achievements
Rank 1
answered on 05 Sep 2012, 01:44 PM

Hello,

I have the same problem as described above. I want  radGrid column to display the  numeric values with a specific decimal and group separator in display mode.

Did you find any solutions to the above problem?

Thanking you in advance.

0
Eyup
Telerik team
answered on 07 Sep 2012, 01:10 PM
Hello,

Please try the following approach:
<telerik:GridNumericColumn ... DataFormatString="{0:##,#0.000}">

For additional customization, please refer to the following topic:
http://msdn.microsoft.com/en-us/library/0c899ak8.aspx

I hope this will prove helpful. Please give it a try and let me know about the result.

All the best,
Eyup
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Kavitha
Top achievements
Rank 1
answered on 07 Sep 2012, 04:00 PM

<telerik:GridNumericColumn ... DataFormatString="{0:##,#0.000}">

The above dataformatString "{0:##,#0.000}" displays the value 123456789.5678 as 123,456,789.568 in english culture.

But I want my column to display my specific decimal and group separator.

For example, I have set “*” as decimal separator and “@” as group separator, my grid column should display 123@456@789*568

I read that GridNumericColumn has RadNumericTextBox in edit mode. I can set RadNumericTextBox’s decimal and group separator to edit my value.

Do you have any solutions to display and edit my decimal value in grid according to my decimal separator “*” and group separator “@”?


Thanks for the reply.
0
Eyup
Telerik team
answered on 12 Sep 2012, 02:08 PM
Hello Kavitha,

In this case you will need to access the auto-generated RadNumericTextBox in edit mode and modify the cell text in regular view. Please try the following approach:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
{
    if (e.Item is GridEditableItem && e.Item.IsInEditMode)
    {
        GridEditableItem editItem = e.Item as GridEditableItem;
        RadNumericTextBox numBox = editItem["Freight"].Controls[0] as RadNumericTextBox;
        numBox.NumberFormat.GroupSeparator = "@";
        numBox.NumberFormat.DecimalSeparator = "*";
    }
    else if (e.Item is GridDataItem)
    {
        GridDataItem dataItem = e.Item as GridDataItem;
        GridTableCell cell = dataItem["Freight"] as GridTableCell;
        string formattedNumber = string.Format("{0:##,#0.000}", decimal.Parse(cell.Text),
            System.Globalization.CultureInfo.InvariantCulture);
        cell.Text = formattedNumber.Replace(',', '@').Replace('.', '*');
    }
}

That should do the trick. Please try it out and let me know if it helps you.

Regards,
Eyup
The Telerik Team
0
Kavitha
Top achievements
Rank 1
answered on 17 Sep 2012, 02:50 PM
Hai Eyup

Your solution worked well.
Thanks for the reply.
Tags
Grid
Asked by
Asp Net
Top achievements
Rank 1
Answers by
Jayesh Goyani
Top achievements
Rank 2
Asp Net
Top achievements
Rank 1
Kavitha
Top achievements
Rank 1
Eyup
Telerik team
Share this question
or