nervo
9 Aug 2007, 11:58 PM
Hello,
I'm looking for a way to get a file upload cell for each row in a editor datagrid. I've tried some solutions :
1) In the renderer :
renderer: function(data){
return '<div id=\"form_div\">'
+ '<form class=\"x-form\" method=\"post\">'
+ '<div class=\"x-form-ct\">'
+ '<div class=\"x-form-item\">'
+ '<div class=\"x-form-element\">'
+ '<input type=\"file\" name=\"contract\" id=\"field_upload_\" autocomplete=\"off\" size=\"20\" class=\"x-form-file x-form-field\" />'
+ '</div>'
+ '</div>'
+ '</div>'
+ '</form>'
+ '</div>';
}
Just copy/pasted html from another form. I can not handle file submission this way, as the renderer can only return html, no way to create form, or fields dynamically, nor add handlers to submit.
2) In the editor:
editor: new Ext.grid.GridEditor(new Ext.form.TextField({
id: 'field_upload',
inputType: 'file',
name: 'contract'
}))
This way seems better, but i receive a "Security error" code: "1000" in firebug. This is - i think - due to the GridEditor object which try to set a value to the file input, which is strictly forbidden, or something like that.
Well, so i decided to write a new inherited class of TextField, called UploadField, with inputType property pre-defined to 'file', and to catch all value related methods, to nullify them. Here it is :
UploadField = function(config){
UploadField.superclass.constructor.call(this, config);
};
Ext.extend(UploadField, Ext.form.TextField,{
inputType: 'file',
processValue : function(value){
return value;
},
validateValue : function(value){
return true;
},
setRawValue : function(v){},
setValue : function(v){}
});
But no success...
I have also think about a way to insert directly a form in a cell..
Do you, men, think i am in the good direction (renderer/editor/form in a cell) ? Do you see another way(s) ?
I'm looking for a way to get a file upload cell for each row in a editor datagrid. I've tried some solutions :
1) In the renderer :
renderer: function(data){
return '<div id=\"form_div\">'
+ '<form class=\"x-form\" method=\"post\">'
+ '<div class=\"x-form-ct\">'
+ '<div class=\"x-form-item\">'
+ '<div class=\"x-form-element\">'
+ '<input type=\"file\" name=\"contract\" id=\"field_upload_\" autocomplete=\"off\" size=\"20\" class=\"x-form-file x-form-field\" />'
+ '</div>'
+ '</div>'
+ '</div>'
+ '</form>'
+ '</div>';
}
Just copy/pasted html from another form. I can not handle file submission this way, as the renderer can only return html, no way to create form, or fields dynamically, nor add handlers to submit.
2) In the editor:
editor: new Ext.grid.GridEditor(new Ext.form.TextField({
id: 'field_upload',
inputType: 'file',
name: 'contract'
}))
This way seems better, but i receive a "Security error" code: "1000" in firebug. This is - i think - due to the GridEditor object which try to set a value to the file input, which is strictly forbidden, or something like that.
Well, so i decided to write a new inherited class of TextField, called UploadField, with inputType property pre-defined to 'file', and to catch all value related methods, to nullify them. Here it is :
UploadField = function(config){
UploadField.superclass.constructor.call(this, config);
};
Ext.extend(UploadField, Ext.form.TextField,{
inputType: 'file',
processValue : function(value){
return value;
},
validateValue : function(value){
return true;
},
setRawValue : function(v){},
setValue : function(v){}
});
But no success...
I have also think about a way to insert directly a form in a cell..
Do you, men, think i am in the good direction (renderer/editor/form in a cell) ? Do you see another way(s) ?