mardi 30 septembre 2014

Easy One - Small working snipit to improve

The following snip of code is working great, but how would I get the grid without using getCmp and what else is done poorly? It is the onExpandBody function usingRowExpander in 4.2.3 in Architect (Grid promoted to a class and the onExpandBody is in the controller). Most of it is obviously developed from looking at a thousand examples:

onExpandBody: function(rowNode, record, expandRow) {

var containerName = "OrderRow" + record.get('OrderNumber'),

grid = Ext.getCmp ('grdOrders'); //go up from the node?




// See if the panel already exists from a previously expanded row and kill it.

var oldPanel = Ext.getCmp('pnlOrderRow');

if (oldPanel !== undefined) {

oldPanel.destroy();

}




// Collapse the prevoiusly expanded row

if (this.lastExpandedRowIdx !== undefined && this.lastExpandedRowIdx !== rowNode.rowIndex){

var rowex = grid.getPlugin('OrdersRowExpander');

var row = Ext.get(rowex.view.getNode(this.lastExpandedRowIdx));

row.addCls(rowex.rowCollapsedCls);

}




// store the currently expanded row index

this.lastExpandedRowIdx = rowNode.rowIndex;




// Create the panel inside the row

var holderPanel = Ext.create("SalesOrderHistory.view.pnlOrderRow");

holderPanel.render(containerName);

// I don't know why I have the following line

holderPanel.getEl().swallowEvent(['mouseover', 'mousedown', 'click', 'dblclick']);




// Load all the sotres on the details panel

var newURL = baseURL + 'jsonWeb.p?mode=OrderLines&orderNo=' + record.get('OrderNumber') +

'&SessionToken=' + SessionToken;

var ds = Ext.getStore('strOrderLine');

ds.proxy.url = newURL;

ds.load();




},






Easy One - Small working snipit to improve

Aucun commentaire:

Enregistrer un commentaire