I want with extjs 4.2
I use this component in attachment :
{
xtype: 'filefield',
id: 'file6',
fieldLabel: 'test ',
labelWidth: 100,
msgTarget: 'side',
allowBlank : false,
anchor: '100%',
buttonText: 'upload'
},
I want to have a attachment component which display name of file without this text : c /fakepath
There isn't a built-in way to accomplish this however, you can do a find/replace for fakepath and remove. I impelmented this on the change
event. Here is an example:
listeners: {
change: function(fld, value) {
var newValue = value.replace(/C:\\fakepath\\/g, '');
fld.setRawValue(newValue);
}
}
I created a sencha fiddle demonstrating a working example
Similar to user3550464's answer, but in a whole lot less code:
Add this to your file field listeners object. This code will remove all text up to and including the last slash or backslash in the field.
change: function (field, value) {
'use strict';
var newValue = value.replace(/(^.*(\\|\/))?/, "");
field.setRawValue(newValue);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With