breckster
12 Jun 2008, 8:35 AM
How do you control the "Double-Click" action of a Ext.nd.UIView so I could
disable it ..making the view "read only" or redirecting the url target of the line item to point somewhere else other than the document shown in the view?
thanks
Breck
JimStoner
12 Jun 2008, 9:47 AM
In Beta 1 there isn't a way to configure this (as far as I could find out).
However, you can simply override the event handler that gets fired when a user double clicks on a row in the grid. Here's some code I used to force the document to open in the same window rather than a new window:
myView = new Ext.nd.UIView({
viewName: 'Recent Requests',
singleSelect : true,
showSearch : false,
gridConfig: {
renderTo: 'RequestsDiv',
width:750,
height:500
}
});
myView.gridHandleRowDblClick = function(grid, rowIndex, e, bEditMode) {
var mode = (bEditMode) ? '?EditDocument' : '?OpenDocument';
var title = "Opening...";
var ds = grid.getStore();
var row = grid.getSelectionModel().getSelected();
var node = row.node;
var unid = node.attributes.getNamedItem('unid');
// if a unid does not exist this row is a category so bail
if (!unid) {
return;
} else {
unid = unid.value;
}
var panelId = 'pnl-' + unid;
var viewUrl = this.getViewUrl(grid);
var link = viewUrl + '/' + unid + mode;
document.location = link;
};
Basically, you need to know the name of the UIView object, which is myView in the example above. Then you just redefine the method myView.gridHandleRowDblClick to do whatever you want.
Take a look at the ext/2.0.1/ext-all-debug.js file in the Ext.nd_b1.nsf database to see the actual code. Search for the gridHandleRowDblClick method and you'll see that all it does is call a private method called openDocument. The openDocument method sets some variables, then checks to see if the view is inside a panel or not. If not, it opens the selected document in a new window, otherwise it opens a new panel.
In my case, I'm not using panels so the second half of the openDocument method was unneeded. I just took everything down to the point of opening the selected document in a new window, copied it into my JS header as a new version of gridHandleRowDblClick, and changed the line that opened a new window so it just changes the location of the current window. That is what the code above does.
Hope that helps!
Jim
Powered by vBulletin® Version 4.1.5 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.