Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
2060
Different formatting when viewing and editing in UltraTextEditor
posted

Is it possible to use different formatting settings for the data displayed by a bound UltraTextEditor when it is being viewed and when it is being edited?

The behaviour I am particularly looking for in this instance is similar to Excel, where a number is shown with a pre-configured number of decimal places with comma separators when it isn't being edited, but switches to show all of the decimal places and no commas when the user is editing the value.

 I suppose what I really want to be able to do is to set the .Net String.Format property for the data in the control separately depending on whether the control is in View or Edit state.

I have worked through this post http://forums.infragistics.com/forums/t/6140.aspx, but like that guy I don't really want to use a masked control as I don't want a fixed number of decimal places when editing (just when viewing).  I tried the suggestion there of creating a data filter, but that only works on what is displayed when you are viewing, the mask takes over when you are editing and so you are stuck with a fixed number of decimal places again.

I suppose one option is to roll my own control based on two UltraTextEditors inside a UltraControlContainerEditor; that would allow me to use two datafilters, one for the Edit text editor and one for the view text editor, and to set the different formats for data in the text editors via those datafilters.

That might work, but it seems a long way round, is there an easier way?

 

Parents
No Data
Reply
  • 469350
    Offline posted

    Hi,

    I must be missing something.

    The Format property of a cell only applies when that cell/control is not in edit mode. So it seems to me that if you use a format that limits the number of decimal places displayed and also shows the digit grouping separators (commas), then that's all you need to do. When the cell/control enters edit mode, the user will see the raw data without the separators and including all of the digits.

    So... what's giving you trouble here?

     

Children
  • 2060
    Offline posted in reply to Mike Saltzman

    Hi Mike, thanks for the speedy response.  There are a couple of issues I'm having:

     

    First, there is no Format property on a vanilla UltraTextEditor is there? (I got that from here http://news.infragistics.com/forums/p/6063/26556.aspx )

    To get round that I have set the format via  Properties Pane->Data Bindings->Advanced.  That formatting then gets applied to both the View and Edit state - presumably because this is being done before the control gets the data?   That's not the behaviour I need because it means that the reduced number of decimal places and comma separators are still there when the user edits.

    (That only works at all if I bind the UltraTextEditor's Text property rather than its Value property.)

    Obviously the UltraNumericEditor has a FormatString property, but the UltraNumericEditor requires you to define a fixed number of decimal places via the mask I believe, so I can't use it.  

    I also really want to define a view format that says "If there are two or less decimal places, then show 2dp, if there are more then show them all" which is something that can be done with .net formatting, but I don't think that can be done with the Infragistics style formatting strings?  I think the Infragistics formatting strings are different to the .net ones?

     

    Second:  The value I'm binding to is a Decimal with 18 decimal places.  Depending on how I bind the control and which control I use I keep getting all 18 of the decimal places when I start editing the data (this only occurs after I have round-tripped the data to and from SQL Server).  That was what made me think I need to be able to format the edit mode as well as the view mode as I could use a format to knock off the superfluous trailing zeros.