Hello,
I need to customize the resources window (when adding/removing assigned persons).
The idea is, that a specific person has permission to populate some tasks with some persons.
For example, the leader of a team can add only people of his team, to tasks where the parent task is assigned to his team.
I can do that permissions logic, I just need to know how to disable/hide some resources when resources window is opened.
Thank you.
7 Answers, 1 is accepted
Hello Igor,
The Gantt by default does not allow manipulation of the resource grid but you can access it and hide rows conditionally by overriding some of its internal functions:
var original_createResourceEditor = kendo.ui.Gantt.prototype._createResourceEditor
kendo.ui.Gantt.prototype._createResourceEditor = function (container, options) {
original_createResourceEditor.call(this, container, options);
var resourceEditorGrid = this._resourceEditor.grid;
resourceEditorGrid.element.find(".k-grid-content tr")
.each(function (index, rowElement) {
var rowDataItem = resourceEditorGrid.dataItem(rowElement);
if (rowDataItem.name == "Thomas Hardy") {
$telerik.$(rowElement).hide();
}
})
}
Regards,
Peter Milchev
Progress Telerik
Hello Peter,
Thank you for the answer, unfortunately, I was not able to use this code successfully.
I put the code to window.onload function. The function _createResourceEditor is not triggered.
Is it possible, that this code is for Kendo and not for ASP.NET ajax?
Hello Igor,
The provided script should be placed after the RadScriptManager and should not be in window.onload or any other event handler.
<script>
var original_createResourceEditor = kendo.ui.Gantt.prototype._createResourceEditor;
kendo.ui.Gantt.prototype._createResourceEditor = function (container, options) {
original_createResourceEditor.call(this, container, options);
var resourceEditorGrid = this._resourceEditor.grid;
resourceEditorGrid.element.find(".k-grid-content tr")
.each(function (index, rowElement) {
var rowDataItem = resourceEditorGrid.dataItem(rowElement);
// your custom logic here...
if (rowDataItem.name == "Thomas Hardy") {
$telerik.$(rowElement).hide();
}
})
}
</script>
Regards,
Peter Milchev
Progress Telerik
Now it is working.
Thank you.
Hello,
this solution has another bug, when something is changed in Resources table (New resource assigned, etc.),
all rows, hidden also are visible again.
How can I fox this please?
Thank you
Hello Igor,
The grid is rebinding when checking/unchecking a resource, so the same functionality needs to be executed in the dataBound event:
var original_createResourceEditor = kendo.ui.Gantt.prototype._createResourceEditor
kendo.ui.Gantt.prototype._createResourceEditor = function (container, options) {
original_createResourceEditor.call(this, container, options);
var resourceEditorGrid = this._resourceEditor.grid;
hideResource();
function hideResource() {
resourceEditorGrid.element.find(".k-grid-content tr")
.each(function (index, rowElement) {
var rowDataItem = resourceEditorGrid.dataItem(rowElement);
if (rowDataItem.name == "Thomas Hardy") {
$telerik.$(rowElement).hide();
}
})
}
resourceEditorGrid.bind("dataBound", hideResource);
}
Regards,
Peter Milchev
Progress Telerik
Hello Peter,
Now it is ok.
Thank you.