madcapnmckay/Knockout-UI — Issue #4: Can not use Context Menu in tree View
Author: sunilmittal22
Created: 2011-10-13 15:27:25+00:00
State: open

Hi Man,

I am exploring your UI Widgts and I really love them . They perform exceptionally well. But I found some minor issue I think the issue is bit logical. On treeview right now there is no way I can not distinguish between a Right Click and Left Click,. On Right Click on Node I want to show some advanced options and on left click on the Node I want to display details against that Node.

To Made few changes in ui-tree.js to make it working :

1) In ui-tree.js on Line No 97, I did few changes
/*Original Script */
this.selectNode = function () {
var selected = this.viewModel.selectedNode(), that = this;

if (selected !== undefined && selected.isRenaming()) {
$('.rename > .node input', viewModel.tree).blur();
}
this.saveState();

if (selected === undefined || (selected !== undefined && selected !== this)) {

that.viewModel.handlers.selectNode(this, function () {
if (selected !== undefined) {
selected.isSelected(false);
selected.isRenaming(false);
}
that.isSelected(true);
that.viewModel.selectedNode(that);
that.saveState();
});
}
}.bind(this);

/* End */

/*Modified Script*/
this.selectNode = function (event) {
var selected = this.viewModel.selectedNode(), that = this;

if (selected !== undefined && selected.isRenaming()) {
$('.rename > .node input', viewModel.tree).blur();
}
this.saveState();

if (selected === undefined || (selected !== undefined && selected !== this)) {

that.viewModel.handlers.selectNode(event,this, function () {
if (selected !== undefined) {
selected.isSelected(false);
selected.isRenaming(false);
}
that.isSelected(true);
that.viewModel.selectedNode(that);
that.saveState();
});
}
}.bind(this);

/* End */

If I am missing something, using which I won't be requiring to change the above. Anyways , I wanted to let you about this.

Thanks Man.. Keep up the Good Work