Hi,<div><br></div><div>I am new to ExtJS. Can someone guide me on how I should proceed if I wish to upload a excel using button in the Toolbar.</div><div><br></div><div>This is a code that I got from searching but it is not working,</div>
<div><br></div><div><div>action = new Ext.Action({</div><div> text: "Upload Excel",</div><div> handler: function () {</div><div> alert("This will help upload the excel");</div><div> },</div>
<div> control: new Ext.create('Ext.form.Panel', {</div><div><span class="Apple-tab-span" style="white-space:pre">                                </span>title: 'Upload a CSV File',</div><div><span class="Apple-tab-span" style="white-space:pre">                                </span>width: 400,</div>
<div><span class="Apple-tab-span" style="white-space:pre">                                </span>bodyPadding: 10,</div><div><span class="Apple-tab-span" style="white-space:pre">                                </span>frame: true,</div><div><span class="Apple-tab-span" style="white-space:pre">                                </span>renderTo: Ext.getBody(),</div>
<div><span class="Apple-tab-span" style="white-space:pre">                                </span>items: [{</div><div><span class="Apple-tab-span" style="white-space:pre">                                        </span>xtype: 'filefield',</div><div><span class="Apple-tab-span" style="white-space:pre">                                        </span>name: 'csv',</div>
<div><span class="Apple-tab-span" style="white-space:pre">                                        </span>fieldLabel: 'CSV Upload',</div><div><span class="Apple-tab-span" style="white-space:pre">                                        </span>labelWidth: 50,</div><div><span class="Apple-tab-span" style="white-space:pre">                                        </span>msgTarget: 'side',</div>
<div><span class="Apple-tab-span" style="white-space:pre">                                        </span>allowBlank: false,</div><div><span class="Apple-tab-span" style="white-space:pre">                                        </span>buttonText: 'Select CSV File'</div><div><span class="Apple-tab-span" style="white-space:pre">                                </span>}],</div>
<div><span class="Apple-tab-span" style="white-space:pre">                                </span></div><div><span class="Apple-tab-span" style="white-space:pre">                                </span>buttons: [{</div><div><span class="Apple-tab-span" style="white-space:pre">                                        </span>text: 'Upload',</div>
<div><span class="Apple-tab-span" style="white-space:pre">                                        </span>handler<span class="Apple-tab-span" style="white-space:pre">        </span>: function() {</div><div><span class="Apple-tab-span" style="white-space:pre">                                                </span>var form = this.up('form').getForm();</div>
<div><span class="Apple-tab-span" style="white-space:pre">                                                </span>if(form.isValid()){</div><div><span class="Apple-tab-span" style="white-space:pre">                                                        </span>form.submit({</div><div><span class="Apple-tab-span" style="white-space:pre">                                                                </span>url: 'file-upload.py',</div>
<div><span class="Apple-tab-span" style="white-space:pre">                                                                </span>waitMsg: 'Uploading the CSV File...',</div><div><span class="Apple-tab-span" style="white-space:pre">                                                                </span>success: function(fp, o) {</div>
<div><span class="Apple-tab-span" style="white-space:pre">                                                                        </span>Ext.Msg.alert('Success', 'Your csv file "' + o.result.file + '" has been uploaded.');</div><div><span class="Apple-tab-span" style="white-space:pre">                                                                </span>}<span class="Apple-tab-span" style="white-space:pre">        </span></div>
<div><span class="Apple-tab-span" style="white-space:pre">                                                        </span>});<span class="Apple-tab-span" style="white-space:pre">        </span></div><div><span class="Apple-tab-span" style="white-space:pre">                                                </span>}<span class="Apple-tab-span" style="white-space:pre">        </span></div>
<div><span class="Apple-tab-span" style="white-space:pre">                                        </span>}</div><div><span class="Apple-tab-span" style="white-space:pre">                                </span>}]</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>}),</div>
<div> map: map,</div><div> // button options</div><div> tooltip: "Upload CSV File",</div><div> // check item options</div><div> group: "newTool"</div><div>});</div><div>actions["upCSV"] = action;</div>
<div>toolbarItems.push(action);</div><div><br></div>-- <br>Thanks & Regards<div>Smaran Harihar</div><br>
</div>