Created
April 24, 2012 22:03
-
-
Save wedgybo/2484199 to your computer and use it in GitHub Desktop.
treeview event
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// In my controller control config | |
'organisation positions treeview': { | |
beforedrop: this.updatePositions, | |
drop: this.saveHierarchy | |
}, | |
// The update positions function. | |
updatePositions: function(node, source, model, pos, dropFn, options) { | |
var item = source.records[0]; | |
if (item instanceof HOD.model.Employee) { | |
if (model.isRoot()) { | |
return false; | |
} | |
var found = this.getPositionsStore().getRootNode().findChildBy(function(child) { | |
if (child.get('employee') == item.get('id')) { | |
return true; | |
} | |
}, this, true); | |
// If we have a position filled by an employee already | |
// cancel the dorp | |
if (found) { | |
return false; | |
} | |
model.set('employee', item.get('id')); | |
model.set('employeeName', item.get('fullName')); | |
model.set('employeeType', 'Employee'); | |
model.set('icon', '/resources/images/16/basic2-101.png'); | |
item.set('jobTitle', model.get('roleTitle')); | |
model.eachChild(function (child) { | |
child.dirty = false; | |
}); | |
dropFn = function() {}; | |
fakeDrop = true; | |
} | |
if (item instanceof HOD.model.Role) { | |
var position = Ext.create('HOD.model.Position'); | |
position.set('role', item.get('id')); | |
position.set('roleTitle', item.get('title')); | |
position.set('icon', '/resources/images/16/basic2-110.png'); | |
model.appendChild(position); | |
model.dirty = false; | |
position.dirty = false; | |
dropFn = function() {}; | |
fakeDrop = true; | |
} | |
return true; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment