java - form.submit not working while file upload in ExtJS -
i using extjs 4.2.0 uploading file functionality. when try upload using form.submit(), gives me extjs error , service not called. below code form panel:
ext.define('modelname.view.attachdocumentpanel', { extend: 'ext.form.panel', alias: 'widget.attachdocumentpanel', id: 'attachdocumentpanel', itemid: 'attachdocumentpanel', name: 'attachdocumentpanel', height:25, layout:'column', requires: [ 'modelname.common.util' ], initcomponent: function() { var me = this; ext.applyif(me, { items: [ { xtype: 'filefield', itemid: 'fileuploadfield', id: 'fileuploadfield', name: 'fileuploadfield', emptytext : 'select file upload', msgtarget: 'side', allowblank: false, anchor: '100%', hidelabel: true, columnwidth: .25, buttontext: 'browse' }, { xtype : 'button', text : 'upload', columnwidth: .75, itemid: 'uploaddocumentbutton', name: 'uploaddocumentbutton' } ] }); me.callparent(arguments); } });
and handler code upload button in controller class:
onuploadclick: function(button) { var form = button.up('attachdocumentpanel').getform(); var filename2 = ext.getcmp("fileuploadfield").getvalue(); if(ext.isempty(filename2)) { ext.msg.alert('warning','no file selected !'); form.reset(); return; } if (form.isvalid()) { form.submit({ url: 'http://localhost:8080/war_project/rest/service/ticket/uploadfile', waitmsg:'uploading document...', success: function(form, action) { ext.msg.alert('success', action.result.msg); }, failure: function(form, action) { ext.msg.alert('failure', action.result.msg); } }); } }
when clicking on upload gives me extjs generic error stating undefined. please help.
this works me. try one
if (form.isvalid()) { form.submit({ url: 'http://localhost:8080/war_project/rest/service/ticket/uploadfile', waitmsg: 'uploading please wait...', method: 'post', success: function (r, a) { console.log('success message here') }, failure: function (r, a) { console.log('failure message here') } }); }
Comments
Post a Comment