PDA

View Full Version : Duplicated RowContextMenu



leolima
14 May 2009, 11:46 AM
Hi

I was using Ext 2.2, today I tried the new 3.0, I just changed the ext js files, and during the tests I found some that I could not recoginize if is a bug or its a version conflict.
The code bellow its working 100% into 2.2, using 3.0 the rowcontextmenu appears duplicated when I right click in a same row twice.

Process:
Select a row, right click it, the rowcontextmenu is shown all right, after select another row and donīt right click it, select the previous row and right click it, now you might see the rowcontextmenu duplicated.

Anyone got this error too ?

Thanks




/**
* @author leonardo
*/
var ds = new Ext.data.GroupingStore({
// load using HTTP
proxy: new Ext.data.HttpProxy({
url: '../pedido/Painel_Listagem.econtrole',
method: "GET"
}),
reader: new Ext.data.JsonReader({
root: 'itens',
totalProperty: 'results',
id: 'Id'
}, [{
name: 'Id',mapping: 'Id',type: 'int'
}, {
name: 'Data',mapping: 'Data'}
, {name: 'Hora',mapping: 'Hora',type: 'string' }
, {name: 'FormaPagamento',mapping: 'FormaPagamento',type: 'string' }
, { name: 'Valor',mapping: 'Valor',type: 'float'}
, {name: 'Parcelas',mapping: 'Parcelas',type: 'int'}
, {name: 'PrazoEntrega',mapping: 'PrazoEntrega',type: 'string'}
, {name: 'Local',mapping: 'Local',type: 'string'}
, {name: 'Quantidade',mapping: 'Quantidade',type: 'int'}
, {name: 'Status',mapping: 'Status',type: 'string'}
, {name: 'Cliente',mapping: 'Cliente',type: 'string'
}]),
sortInfo: {field: 'Data',direction: "DESC"},
groupField: 'Data',
remoteSort: true
});


var summary = new Ext.grid.GroupSummary();


var cm = new Ext.grid.ColumnModel([{
header: "Id",width: 20,dataIndex: 'Id',sortable: true,align: 'center'}
, {header: "Data",width: 35,dataIndex: 'Data',sortable: true}
, {header: "Hora",width: 20,dataIndex: 'Hora',sortable: true}
, {header: "Cliente",width: 100,dataIndex: 'Cliente',sortable: true}
, {header: "Forma de Pagamento",width: 80,dataIndex: 'FormaPagamento',sortable: true}
, {header: "R$ Valor",width: 40,dataIndex: 'Valor',sortable: true,align: 'center',summaryType: 'sum',
summaryRender: function(x){
return 'Total ' + helper.brMoney(x);
},
renderer: function(v){
return helper.brMoney(v);
}
}
, {header: "Parc.",width: 20,dataIndex: 'Parcelas',sortable: true,align: 'center'}
, {header: "Prazo de Entrega",width: 50,dataIndex: 'PrazoEntrega',sortable: true,
renderer: function(v){
var valores = v.split(";");
return "<span style=\"width:100% !important; text-align:center; padding:0 0 0 29%; color:" + valores[0] + ";\">" + valores[1] + "</span>";
}
}
, {header: "Local",width: 110,dataIndex: 'Local',sortable: true}
, {header: "Qtd",width: 13,dataIndex: 'Quantidade',sortable: true,align: 'center'}
, {header: "Status",width: 70,dataIndex: 'Status',sortable: true
}]);

if (!grid) {
grid = new Ext.grid.GridPanel({
ds: ds,
cm: cm,
renderTo: 'listagem',
loadMask: true,
trackMouseOver: true,
height: 400,
view: new Ext.grid.GroupingView({
forceFit: true,
showGroupName: false,
enableNoGroups: false // REQUIRED!
,
hideGroupedColumn: true,
groupTextTpl: '({text} {[values.rs.length]} {[values.rs.length > 1 ? "Items" : "Item"]})'
}),
plugins: summary
});

ds.load({
params: {
data_inicial: new Date(data_um.getValue()).format('d/m/y'),
data_final: new Date(data_dois.getValue()).format('d/m/y'),
id_grupo: $('id_grupo').value,
id_forma: $('id_forma').value,
status: $('status').value
}
});

grid.render();

}
else {
grid.store.reload({
params: {
data_inicial: new Date(data_um.getValue()).format('d/m/y'),
data_final: new Date(data_dois.getValue()).format('d/m/y'),
id_grupo: $('id_grupo').value,
id_forma: $('id_forma').value,
status: $('status').value
}
});
}

grid.on("rowcontextmenu", function(grid, index, event){
event.stopEvent();
var record = grid.getStore().getAt(index);
var fieldName = grid.getColumnModel().getDataIndex(0);
var qtdField = grid.getColumnModel().getDataIndex(3);
data = record.get(fieldName);
qtd = record.get(qtdField);
var rowMenu = new Ext.menu.Menu({
id: 'rowMenu',
items: [{
text: 'Dados Gerais',
iconCls: 'x-menu-item-edit',
href: '../pedido/painel.econtrole?Alteracao&Id=' + data
}, {
text: 'Pagamento',
iconCls: 'x-menu-item-edit',
href: '../pedido/painel.econtrole?Alteracao&Id=' + data + '&Sub=Pagamento'
}, {
text: 'Cliente',
iconCls: 'x-menu-item-edit',
href: '../pedido/painel.econtrole?Alteracao&Id=' + data + '&Sub=Cliente'
}, {
text: 'Envio',
iconCls: 'x-menu-item-edit',
href: '../pedido/painel.econtrole?Alteracao&Id=' + data + '&Sub=Envio'
}]
});

rowMenu.showAt(event.getXY());
});

15 May 2009, 6:46 AM
why do you recreate a new menu each time?

leolima
20 May 2009, 8:21 AM
hehehe dammit its true!!
I didnīt saw this bug into my code rs
I will fix it and later I post if this error stoped or not

Thanks Jay