PDA

View Full Version : rowclick event cancels rowdblclick event in gridPanel



flamant
26 May 2011, 7:49 AM
Hi,
I implemented a grid with a rowclick listener and a rowdblclick listener.

Unfortunately when I double click on a row only rowclick is fired

Thank you in advance for your answers

fay
26 May 2011, 8:01 AM
Something else must be up, as I put the following in the "\examples\grid\array-grid.js" example and it works fine:



var grid = new Ext.grid.GridPanel({
// ...
listeners: {
rowclick: function(grid, rowIndex, e){ console.log('click:' + rowIndex); },
rowdblclick: function(grid, rowIndex, e){ console.log('dblclick:' + rowIndex); }
}
});

flamant
26 May 2011, 8:35 AM
Hi fay and thank you for your answer,

In fact I do something in the rowclick handler that must cancel the rowdblclick event but I don't see what

here is the rowclick handler:



rowclick: function(grid, rowIndex, evt) {
console.log('rowclick');
var record = grid.selModel.getSelected();
updateQueryGridButtonVisibility(record, this.messageType, false);
openScreenFromQuery(record);


with this openScreenFromQuery function



function openScreenFromQuery(record) {
var centerIdFromQuery = record.get('center');
if (centerIdFromQuery == 0) {
var subjectId = record.get('subjectId');
var activityId = record.get('activityId');
var screenId = record.get('screenId');
var screenSequence = record.get('seq');
var centerCombo = Ext.getCmp("centerSearch");
var protocolId = centerCombo.selectedProtocolId;
var centerId = centerCombo.selectedCenterId;
var activityPath = '/subjectRoot/Center[' + protocolId + '*' + centerId + ']/Subjects[' + protocolId + '*' + centerId + ']/Subject[' + subjectId + ']/Activity[' + subjectId + '*' + activityId + ']';
var tree = Ext.getCmp('subjectTreeView');
tree.expandPath(activityPath, 'id', function(success, node) {
var nodeId = 'Screen[' + subjectId + '*' + screenId + '*' + screenSequence + ']';
var screenNode = tree.getNodeById(nodeId);
collapsePanel = false;
tree.fireEvent('click', screenNode);
});
}
}


when I comment the "openScreenFromQuery(record);" line it works fine

flamant
28 May 2011, 7:56 AM
Hi,

when I comment the following lines (called in the grid click handler)



// tree.expandPath(activityPath, 'id', function(success, node) {
// var nodeId = 'Screen[' + subjectId + '*' + screenId + '*' + screenSequence + ']';
// var screenNode = tree.getNodeById(nodeId);
// collapsePanel = false;
// tree.fireEvent('click', screenNode);
// });


The grid rowclick and the rowdblclick handler are both fired when I double click on a row

But when I take into account the above lines only the grid rowclick handler is fired

It seems that "tree.expandPath" cancels all other event

flamant
14 Jun 2011, 2:09 AM
Hi, i didn't find a solution

I can add that on treepanel I have the listener expandnode :



expandnode: function(node) {
if (node.attributes['entityName'] == 'Activity') {
filterActivity(node.childNodes);
}
addExpandedNode(node);
node.eachChild(function(n) {
if (n.parentNode.attributes['checked']) {
n.getUI().toggleCheck(true);
}
if (n.attributes['dataSigned'] && n.attributes['screenSigned']) {
n.setTooltip('<spring:message code="signature.screenSigned"/>' + ' and ' + '<spring:message code="signature.datasSigned"/>');
} else if (n.attributes['dataSigned']) {
n.setTooltip('<spring:message code="signature.datasSigned"/>');
} else if (n.attributes['screenSigned']) {
n.setTooltip('<spring:message code="signature.screenSigned"/>');
}
});
},


with the two function inside



function filterActivity(childNodes) {
Ext.each(childNodes, function(node) {
hideUnHideNode(this);
});

}




function addExpandedNode(node) {
if (!expandedNodePaths.contains(node.getPath())) {
expandedNodePaths.push(node.getPath());
}
}

skirtle
16 Jun 2011, 9:09 AM
The approach you're taking of commenting out sections of code to try to track down the culprit seems like a good one. I suggest you keep doing it. For example, rather than commenting out the whole of tree.expandPath(), does it help just to comment out the callback function? What about commenting out the code in your expandnode listener? Keep going till you find the cause. It may then be worth stepping in with a debugger to see what other code gets hit.

I doubt it's the cause of your problem but one section of your code did catch my eye...


tree.fireEvent('click', screenNode);

This is an abuse of the click event. Think of fireEvent() as a protected method, only to be called by classes on themselves using this.fireEvent(). The node has not been clicked, so this event should not be firing.