Textbox - strange behaviour with BO left and right trim


Author
Message
Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
Cool Cool
Aaron Young
Aaron Young
StrataFrame User (435 reputation)StrataFrame User (435 reputation)StrataFrame User (435 reputation)StrataFrame User (435 reputation)StrataFrame User (435 reputation)StrataFrame User (435 reputation)StrataFrame User (435 reputation)StrataFrame User (435 reputation)StrataFrame User (435 reputation)
Group: StrataFrame Users
Posts: 277, Visits: 1.1K
That is good to know. I will subclass it and go back to my lazy way of working Smile
Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
I have a sub-classed Infragistics textbox control that removes leading and trailing spaces when the control leaves focus/editing mode. I had assumed the SF text control would do the same rather than put a block on all spaces when editing.

Actually an SF textbox will allow you to have spaces in the middle if you set the BindingFormat to "Text" on the textbox itself.  By default this is not set, but if you set this value to that property (which is empty by default) it should work as you are expecting.

Aaron Young
Aaron Young
StrataFrame User (435 reputation)StrataFrame User (435 reputation)StrataFrame User (435 reputation)StrataFrame User (435 reputation)StrataFrame User (435 reputation)StrataFrame User (435 reputation)StrataFrame User (435 reputation)StrataFrame User (435 reputation)StrataFrame User (435 reputation)
Group: StrataFrame Users
Posts: 277, Visits: 1.1K
Hi Guys,

Thanks for the responses.

The problem I have is not what is written back to the database but more to do with what is returned by a BO field when it is accessed. For example, if you read a value from a BO field that is 20 characters long, then you will see different results depending on the trim settings:-

BO trim is set to left only, myBO.Name returns              "Aaron Young         "

BO trim is set to both left and right, myBO.Name returns "Aaron Young"

Obviously, I can use the trim command on any BO field reference but I want to be lazy and this seems like too much effort when the only problem is the textbox accepting spaces Smile

I have a sub-classed Infragistics textbox control that removes leading and trailing spaces when the control leaves focus/editing mode. I had assumed the SF text control would do the same rather than put a block on all spaces when editing.

I dont want to appear fussy about this but left trim and right trim should allow spaces in the middle of your string. In the above example it would have been impossible to enter "Aaron Young" with left and right trim enabled. As I say I dont want to appear fussy about this but it would be a help if the control would allow spaces Smile

Regards,

Aaron

StrataFrame Team
S
StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
The VarChar will prevent this from needin the Trim, but you can just put "Text" without the quotes in the BindingFormat property of the textbox while using the Trim() options and it will prevent the "weirdness." Smile
Ralph Rutschmann
Ralph Rutschmann
StrataFrame User (131 reputation)StrataFrame User (131 reputation)StrataFrame User (131 reputation)StrataFrame User (131 reputation)StrataFrame User (131 reputation)StrataFrame User (131 reputation)StrataFrame User (131 reputation)StrataFrame User (131 reputation)StrataFrame User (131 reputation)
Group: Forum Members
Posts: 69, Visits: 1.3K
Hello Aron,

I am hoping the left and right trim operation can be done either during the save or when the control loses focus.

I would try the BeforeSave-Event of the BO. Something like: 'this.myBO.toTrimField.Trim();'

But I think Edhy is right, I never had the need to trim anything with varchar-Fields.

HTH, Ralph

Aaron Young
Aaron Young
StrataFrame User (435 reputation)StrataFrame User (435 reputation)StrataFrame User (435 reputation)StrataFrame User (435 reputation)StrataFrame User (435 reputation)StrataFrame User (435 reputation)StrataFrame User (435 reputation)StrataFrame User (435 reputation)StrataFrame User (435 reputation)
Group: StrataFrame Users
Posts: 277, Visits: 1.1K
I believe that if you are using a varchar field type, the spaces will be trimmed when saved to the database.

Hi Edhy,

I am using varchars and the textbox control simply stops spaces from being entered - it happens as soon as the space key is pressed (long before the database save). If I set the trim operation to left only, the control allows spaces but when set to left and right no spaces can be entered.

I am hoping the left and right trim operation can be done either during the save or when the control loses focus.

Aaron

Edhy Rijo
E
StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Ideally, I am only trying to remove leading and trailing spaces rather than all spaces from the entire string.

Have I missed something?

Hi Aaron,

I believe that if you are using a varchar field type, the spaces will be trimmed when saved to the database.

Edhy Rijo

Aaron Young
Aaron Young
StrataFrame User (435 reputation)StrataFrame User (435 reputation)StrataFrame User (435 reputation)StrataFrame User (435 reputation)StrataFrame User (435 reputation)StrataFrame User (435 reputation)StrataFrame User (435 reputation)StrataFrame User (435 reputation)StrataFrame User (435 reputation)
Group: StrataFrame Users
Posts: 277, Visits: 1.1K
Hi,

I have set all my string fields to have left and right trim in the business object mapper. I have just noticed that if you try and enter a value such as "24 My Address" into a text box, the cursor jumps to the start each time a space is entered - it is impossible to enter a space.

Ideally, I am only trying to remove leading and trailing spaces rather than all spaces from the entire string.

Have I missed something?

Thanks in advance,

Aaron

GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search