Ext.define("Compass.ErpApp.Desktop.Applications.ProductManager.ProductsPanel",{ extend:"Ext.panel.Panel", alias:'widget.productmanagement_productspanel', loadProducts : function(){ this.productsDataView.getStore().load(); }, deleteProduct : function(id){ var self = this; Ext.MessageBox.confirm('Confirm', 'Are you sure you want to delete this product?', function(btn){ if(btn == 'no'){ return false; } else { Ext.Ajax.request({ url: '/erp_products/erp_app/desktop/product_manager/delete/'+id, success: function(response) { var obj = Ext.decode(response.responseText); if(obj.success){ self.productsDataView.getStore().load(); } else{ Ext.Msg.alert('Error', 'Error deleting product.'); } }, failure: function(response) { Ext.Msg.alert('Error', 'Error deleting product.'); } }); } }); }, initComponent: function() { Compass.ErpApp.Desktop.Applications.ProductManager.ProductsPanel.superclass.initComponent.call(this, arguments); }, constructor : function(config) { var self = this; this.productsDataView = Ext.create("Ext.view.View",{ autoDestroy:true, itemSelector: 'tr.product-wrap', style:'overflow:auto', store: Ext.create("Ext.data.Store",{ autoLoad: true, proxy:{ type:'ajax', url: '/erp_products/erp_app/desktop/product_manager/', reader:{ root: 'products', type:'json' } }, fields:['imageUrl', 'id', 'title', 'available', 'sold','price','sku'] }), tpl: new Ext.XTemplate( '
Product | ', '# Available | ', '# Sold | ', '
',
'',
' ',
'{title} ',
'', '{price} ', 'SKU # {sku}', ' | ',
'{available} | ', '{sold} | ', '