This is full grid init. Quite long
var gridTasks = cellTasks.attachGrid();
gridTasks.setIconsPath('./codebase/imgs/');
gridTasks.setHeader(["<i class=\"fa fa-check-square-o\"></i>", "Dotyczy (osoba/firma)", "Treść", "Właściciel", "Zlecający", "Termin", "<i class=\"fa fa-repeat\"></i>", "<i class=\"fa fa-arrows-v\"></i>"]);
gridTasks.attachHeader(["#rspan", "#combo_filter", "#rspan", "#combo_filter", "#combo_filter", "#rspan", "#rspan", "#rspan"]);
gridTasks.setColTypes("ro,ro,ro,ro,ro,ro,ro,ro");
gridTasks.setColAlign('center,left,left,left,left,right,center,center');
gridTasks.setColSorting('str,str,str,str,str,date,str,str');
gridTasks.setInitWidths('30,200,*,150,150,80,30,25');
gridTasks.setColumnMinWidth('250', 2);
gridTasks.init();
gridTasks.attachEvent('onXLS', function () {
cellTasks.progressOn();
});
gridTasks.attachEvent('onXLE', function () {
cellTasks.progressOff();
});
gridTasks.attachEvent('onXLE', function () {
gridTasks.forEachRow(function (rId) {
if (gridTasks.getUserData(rId, 'status') == 1) {
gridTasks.cells(rId, 0).setBgColor('#acd824');
} else {
var today = new Date().setHours(0, 0, 0, 0);
//console.log(today <= new Date(gridTasks.cells(id,6).getValue()));
if (today <= new Date(gridTasks.cells(rId, 5).getValue())) {
gridTasks.cells(rId, 0).setBgColor('#ffe9ec');
} else {
gridTasks.cells(rId, 0).setBgColor('#C63059');
}
}
if (gridTasks.getUserData(rId, 'priority') == 0) {
gridTasks.cells(rId, 7).setBgColor('#acd824');
} else if (gridTasks.getUserData(rId, 'priority') == 2) {
//gridTasks.cells(id, 5).setBgColor('#f9f039');
gridTasks.cells(rId, 7).setBgColor('#C63059');
}
});
this.sortRows(5);
this.setSortImgState(true, 5, "asc");
});
var contextTasks = new dhtmlXMenuObject();
contextTasks.setIconset("awesome");
contextTasks.renderAsContextMenu();
contextTasks.loadStruct('<menu>' +
'<item type="item" id="ctxEdit" text="Edycja" img="fa fa-pencil" imgdis="fa fa-pencil" enabled="false"/>' +
'<item type="separator" id="menuitem_separator_1" />' +
'<item type="item" id="ctxCompleted" text="Zakończ" img="fa fa-check-square-o" imgdis="fa fa-check-square-o" enabled="false" />' +
'<item type="item" id="ctxComment" text="Dodaj komentarz" img="fa fa-comment-o" imgdis="fa fa-comment-o" enabled="false" />' +
'<item type="separator" id="menuitem_separator_2" />' +
'<item type="item" id="ctxDelete" text="Usuń" img="fa fa-trash-o" imgdis="fa fa-trash-o" enabled="false"/>' +
'</menu>', function () {
});
contextTasks.attachEvent('onClick', function (bId) {
switch (bId) {
case "ctxDelete":
deleteTask();
break;
case "ctxEdit":
windowEditTask();
break;
case "ctxCompleted":
windowCommentTask(true);
break;
case "ctxComment":
windowCommentTask(false);
break;
}
});
gridTasks.enableContextMenu(contextTasks);
gridTasks.attachEvent('onBeforeContextMenu', function (rId, cellInd, gridObj) {
gridObj.selectRowById(rId, false, false, true);
return true;
});
gridTasks.attachEvent('onRowSelect', function (rId, cInd) {
if (gridTasks.getUserData(rId, 'status') == 1) {
toolbarTasksList.disableItem('buttonEdit');
toolbarTasksList.disableItem('buttonCompleted');
contextTasks.setItemDisabled('ctxEdit');
contextTasks.setItemDisabled('ctxCompleted');
contextTasks.setItemDisabled('ctxComment');
if (gridTasks.getUserData(rId, 'user_id') == UserData['id']) {
toolbarTasksList.enableItem('buttonDelete');
contextTasks.setItemEnabled('ctxDelete');
} else {
toolbarTasksList.disableItem('buttonDelete');
contextTasks.setItemDisabled('ctxDelete');
}
} else {
if (gridTasks.getUserData(rId, 'user_id') == UserData['id']) {
toolbarTasksList.enableItem('buttonEdit');
toolbarTasksList.enableItem('buttonCompleted');
contextTasks.setItemEnabled('ctxEdit');
contextTasks.setItemEnabled('ctxCompleted');
contextTasks.setItemEnabled('ctxComment');
toolbarTasksList.enableItem('buttonDelete');
contextTasks.setItemEnabled('ctxDelete');
} else {
toolbarTasksList.disableItem('buttonEdit');
toolbarTasksList.enableItem('buttonCompleted');
contextTasks.setItemDisabled('ctxEdit');
contextTasks.setItemEnabled('ctxCompleted');
contextTasks.setItemEnabled('ctxComment');
toolbarTasksList.disableItem('buttonDelete');
contextTasks.setItemDisabled('ctxDelete');
}
}
});
gridTasks.attachEvent('onRowDblClicked', function (rId, cIdx) {
windowPreviewTask();
});