Created
November 10, 2010 15:42
-
-
Save veriojon/671008 to your computer and use it in GitHub Desktop.
excel import js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var ExcelErrorDialog = Ext.extend(Ext.Window, { | |
constructor: function(config) { | |
this.importForm = new Ext.FormPanel({ | |
frame: true, | |
bodyStyle: 'padding: 10px 10px 0 10px;', | |
labelWidth: 50, | |
defaults: { anchor: '95%', allowBlank: false, msgTarget: 'side'}, | |
items: [{ | |
xtype: 'displayfield', | |
itemID: 'filename', | |
value: 'My file: ' + this.filename | |
}] | |
}); | |
Ext.apply(this, { | |
title: 'Excel Import Errors', | |
layout:'fit', | |
width:450, | |
height:200, | |
plain: true, | |
modal: true, | |
items: [this.importForm], | |
fbar: [ | |
{text: 'Cancel', tabIndex: 5, handler: this.onCancel, scope: this }, | |
{text: 'Download Errors', tabIndex: 4, handler: this.onDownload, scope: this } | |
] | |
}); | |
ExcelImportDialog.superclass.constructor.apply(this, arguments); | |
}, | |
onCancel: function() { | |
this.close(); | |
}, | |
onDownload: function() { | |
this.hide(); | |
var store = this.store; | |
if(this.importForm.getForm().isValid()){ | |
this.importForm.getForm().submit({ | |
url: this.filename, | |
success: function(fp, o){ | |
this.close(); | |
}, | |
}); | |
} | |
} | |
}); | |
var ExcelImportDialog = Ext.extend(Ext.Window, { | |
constructor: function(config) { | |
this.importForm = new Ext.FormPanel({ | |
fileUpload: true, | |
frame: true, | |
bodyStyle: 'padding: 10px 10px 0 10px;', | |
labelWidth: 50, | |
defaults: { anchor: '95%', allowBlank: false, msgTarget: 'side'}, | |
items: [{ | |
xtype: 'fileuploadfield', | |
//id: 'form-file', | |
emptyText: 'Select an Excel file', | |
fieldLabel: 'File', | |
name: 'data_file', | |
buttonText: '', | |
buttonCfg: { | |
iconCls: 'upload-icon' | |
} | |
}] | |
}); | |
Ext.apply(this, { | |
title: 'Import Excel file', | |
layout:'fit', | |
width:450, | |
height:200, | |
plain: true, | |
modal: true, | |
items: [this.importForm], | |
fbar: [ | |
{text: 'Cancel', tabIndex: 5, handler: this.onCancel, scope: this }, | |
{text: 'Import', tabIndex: 4, handler: this.onImport, scope: this } | |
] | |
}); | |
ExcelImportDialog.superclass.constructor.apply(this, arguments); | |
}, | |
onCancel: function() { | |
this.close(); | |
}, | |
onImport: function() { | |
this.hide(); | |
var store = this.store; | |
if(this.importForm.getForm().isValid()){ | |
this.importForm.getForm().submit({ | |
url: this.import_url, | |
waitMsg: 'Importing your excel file...', | |
success: function(fp, o){ | |
this.close(); | |
Imata.showMessage('Import complete'); | |
store.load(); | |
}, | |
failure: function() { | |
// msg('Error', 'Your import did not complete successfully.'); | |
this.close(); | |
new ExcelErrorDialog({filename: this.outfile}).show(); | |
} | |
}); | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment