/* * Ext JS Library 2.2 * Copyright(c) 2006-2008, Ext JS, LLC. * licensing@extjs.com * * http://extjs.com/license */ var ds = new Ext.data.JsonStore({ url:'ArticoliServlet', id: 'artCodice', totalProperty: 'total', root: 'data', fields: [ {name:'artThumb'}, {name:'artCodice'}, {name:'artDescrizione'}, {name:'natDescriz'}, {name:'artPrezzo1'} ], sortInfo: {field: 'artCodice', direction: 'ASC'}, remoteSort: false }); var TreeTest = function(){ // shorthand var Tree = Ext.tree; var myTreeLoader = new Tree.TreeLoader({dataUrl:'CategorieServlet'}); myTreeLoader.on("beforeload", function(treeLoader, node) {treeLoader.baseParams.lvl = node.attributes.lvl;}, this); return { init : function(){ // yui-ext tree var tree = new Tree.TreePanel({ el:'categorie-tree', title: 'Categorie', animate:true, autoScroll:true, loader: myTreeLoader, enableDD:false, listeners:{ 'click':{ fn: function(node, e){ categoria = node.id; ds.load({params:{category:categoria,start: 0, limit: 15}}); }}}, containerScroll: false, dropConfig: {appendOnly:true} }); // add a tree sorter in folder mode new Tree.TreeSorter(tree, {folderSort:true}); // set the root node var root = new Tree.AsyncTreeNode({ text: 'Categorie', draggable:false, // disable root node dragging id:'null', lvl:'0', cls:'t-lvl-0' }); tree.setRootNode(root); // render the tree tree.render(); root.expand(false, /*no anim*/ false); } }; }(); Ext.EventManager.onDocumentReady(TreeTest.init, TreeTest, true); Ext.onReady(function(){ Ext.menu.RangeMenu.prototype.icons = { gt: 'img/greater_then.png', lt: 'img/less_then.png', eq: 'img/equals.png' }; Ext.grid.filter.StringFilter.prototype.icon = 'img/find.png'; // NOTE: This is an example showing simple state management. During development, // it is generally best to disable state management as dynamically-generated ids // can change across page loads, leading to unpredictable results. The developer // should ensure that stable state ids are set for stateful components in real apps. // Ext.state.Manager.setProvider(new Ext.state.CookieProvider()); var filters = new Ext.grid.GridFilters({ filters:[ {type: 'string', dataIndex: 'artCodice'}, {type: 'string', dataIndex: 'artDescrizione'}, {type: 'string', dataIndex: 'natDescriz'}, {type: 'string', dataIndex: 'artPrezzo1'} ]}); var cm = new Ext.grid.ColumnModel([ {dataIndex: 'artThumb', header: 'Miniatura',width: 118}, {dataIndex: 'artCodice', header: 'Codice articolo', id: 'artCodice',width: 93}, {dataIndex: 'artDescrizione', header: 'Descrizione', id: 'artDescrizione',width: 145}, {dataIndex: 'natDescriz',header: 'Produttore', id: 'natDescriz',width: 75}, {dataIndex: 'artPrezzo1', header: 'Prezzo', id: 'artPrezzo1',width: 70, renderer: 'usMoney',align:'right'} ]); cm.defaultSortable = true; var grid = new Ext.grid.GridPanel({ id: 'articoli', title: 'Articoli', ds: ds, autoSizeColumns: false, cm: cm, enableColLock: true, loadMask: false, plugins: filters, listeners: { cellclick: function(grid, rowIndex, colIndex) { var record = grid.getStore().getAt(rowIndex); var recID = record.get('artCodice'); document.location.href="./SchedaArticoloServlet?articleId=" + recID; } }, height:650, width:520, el: 'articoli-grid' }); grid.render(); ds.load({params:{start: 0, limit: 999}}); });