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

[Solved] Problem with masking in view/edit state

7 Answers 200 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Marc
Top achievements
Rank 1
Marc asked on 03 Jan 2011, 10:23 PM
Using the following code, it is not acting as expected:

<telerik:GridViewMaskedTextBoxColumn DataMemberBinding="{Binding PriceChangePercent}" Header="Price Change Percent" MaskType="Numeric" Mask="p"/>
<telerik:GridViewMaskedTextBoxColumn DataMemberBinding="{Binding MarketValue}" Header="Market Value" MaskType="Numeric" Mask="c"/>

While viewing the cell the mask does not show, when editing the cell you see the mask, but the percent mask moves the numbers around. How can I get the mask to show in the view state, and show the values correctly?

Attached images of the columns above. 

These cells should always be read only. I changed them to be editable to help debug this issue. 

Thanks

7 Answers, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 04 Jan 2011, 09:17 AM
Hi Marc,

In the case of GridViewMaskedTextBoxColumn the editing element is RadMaskedTextBox. Consequently, the properties set are reflected on editing the value. What you may do is do use the DataFormatString property of the column. Furthermore, if you want more of the digits after the decimal point to be displayed, you need to define the Mask more precisely. For example:

<telerik:GridViewMaskedTextBoxColumn DataMemberBinding="{Binding StadiumCapacity}" 
                                    Mask="p4"
                                    MaskType="Numeric"
                                    DataFormatString="{}{0:P4}"/>
   

Kind regards,
Maya
the Telerik team
Browse the videos here>> to help you get started with RadControls for Silverlight
0
Marc
Top achievements
Rank 1
answered on 04 Jan 2011, 05:05 PM
I don't agree with this. A control should never move data around like this control is. When the value in the control is 1.23456789, the control should not display 123.4567. It seems like the control is doing a *100 to the value. 

I used your code:
<telerik:GridViewMaskedTextBoxColumn DataMemberBinding="{Binding PriceChangePercent}"
Header="Price Change Percent" Mask="P4" MaskType="Numeric" DataFormatString="{}{0:P4}" />
It still moved items around. This is a major issue. 

If I set mask why does it not set both viewing and editing? I can see the extra functionality of being able to set viewing and editing separate(for what use I have no idea), but if a user wants this then let them set both. I would think 99% of the time the user will want the edit/view masks to be the same, so why does it not set both masks to be the same, and the user has the ability to overwrite the second mask if they so choose. 

Since this grid is read only I see no benefit in using the GridViewMaskedTextColumn over the GridViewDataColumn since I still have to set the DataFormatString. 
0
Maya
Telerik team
answered on 05 Jan 2011, 08:45 AM
Hi Marc,

As mentioned previously the RadMaskedTextBox is the editing element in the corresponding column. It is the same case with the GridViewComboBoxColumn where the RadComboBox shows up only in edit mode. Furthermore, the fact that the numbers are rounded is due to setting the Mask and MaskType properties. However, if you try to play along with the definition of the Mask - P8 for example, more digits will be displayed.
Thus you may arrange the settings so that they meet your requirements.
 

All the best,
Maya
the Telerik team
Browse the videos here>> to help you get started with Rad
Controls for Silverlight
0
Marc
Top achievements
Rank 1
answered on 05 Jan 2011, 04:20 PM
Your not understanding the issues. 

When I set a mask why does the mask not get set for the editing and viewing controls? Why must I set the mask twice? I understand that the editing and viewing state are different controls, but the mask on both controls should be set at the same time. 

I know that if my number is 1.2345678 and I set a mask of 0.000 that you will see 1.234. Attached is a screen shot(telerik.png). The columns are the same in code. The value is -4.1694242223692900, but when the cell goes to editing it becomes -416.94 %. This is unacceptable. The control is changing the value. With a % mask it should be -4.16 %. Controls should never change values in the cell. I don't see a setting that stops this from happening. I don't want to show more digits, I want the control to stop moving my decimal point. 
0
Vlad
Telerik team
answered on 05 Jan 2011, 04:55 PM
Hello,

 The control in view mode is plain TextBlock which does not have anything closer to masking. Why you need GridViewMaskedTextBoxColumn at all if these cells should always be read only? The main purpose of this column is to edit your data with RadMaskedTextBox - if your scenario is different you should use plain GridViewDataColumn with desired format for the binding or DataFormatString.

Greetings,
Vlad
the Telerik team
Browse the videos here>> to help you get started with RadControls for Silverlight
0
Marc
Top achievements
Rank 1
answered on 05 Jan 2011, 07:45 PM
In this case yes I had to switch back to the base control. I do have a need that will require a masked editor. So these problems will come back up when I get there. 

I will still need to set the Mask, MaskType, and DataFormatString. I don't understand why when I set the Mask and MaskType, it can not set the DataFormatString at the same time. Given the percent example if I set Mask="P4" that should be the same as setting DataFormatString="{}{0.0000}%". 

Also what happens when then Mask property on masked editor is set to P? Why does the number change? Is the control doing a *100 to the value?
0
Petar Mladenov
Telerik team
answered on 10 Jan 2011, 05:01 PM
Hello,

DataFormatString is exactly the same as string.Format() while Mask and MaskType are a bit more complicated.
The Numeric RadMaskedTextBox with mask "P"  uses by default the method ToString() of the type of the value. This formatting basically multiplies the value with 100. You can test it like so;

double value = 68d;
            MessageBox.Show(value.ToString("p"));
So the behavior you have come up with is expected. However, I logged your request as a feature request in our PITS where you will be soon able to vote for ( MaskedTextBox: "P" mask type of the Numeric mask only multiplies value with 100. A way to concatenate "%" to the value is needed ).
Feel free to ask if you need further assistance. We would be glad to help you.

Kind regards,
Petar Mladenov
the Telerik team
Browse the videos here>> to help you get started with RadControls for Silverlight
Tags
GridView
Asked by
Marc
Top achievements
Rank 1
Answers by
Maya
Telerik team
Marc
Top achievements
Rank 1
Vlad
Telerik team
Petar Mladenov
Telerik team
Share this question
or