13
« on: April 13, 2017, 05:08:42 am »
This is my column array below, is there a way that I can add a function to the "hidden" element in the column to decide if it is true or false, it will be whether the columns titles from 104, 105 etc. onwards are in the actual data?
var columnsDetail = [
{
title: "DisplayCols", dataType: "string", dataIndx: "DisplayCols", editable: false, hidden: true
},
{
title: "RecID", dataType: "string", dataIndx: "RecID", editable: false, hidden: true
},
{
title: "EmployeeId", dataType: "integer", dataIndx: "EmployeeId", editable: false, hidden: true
},
{
title: "Employee", dataType: "string", editable: false, dataIndx: "Employee", minWidth: 140, maxWidth: 180, hidden: false,
filter: {
type: "select",
condition: 'equal',
prepend: { '': '-ALL-' },
valueIndx: "Employee",
labelIndx: "Employee",
listeners: ['change']
}
},
{
title: "Emp. No.", dataType: "string", editable: false, dataIndx: "EmployeeNo", minWidth: 70, maxWidth: 70, hidden: false, filter: {
type: "select",
condition: 'equal',
prepend: { '': '-ALL-' },
valueIndx: "EmployeeNo",
labelIndx: "EmployeeNo",
listeners: ['change']
}
},
{
title: "Trade", dataType: "string", editable: false, dataIndx: "TradeName", minWidth: 130, maxWidth: 200, hidden: false, filter: {
type: "select",
condition: 'equal',
prepend: { '': '-ALL-' },
valueIndx: "TradeName",
labelIndx: "TradeName",
listeners: ['change']
}
},
{
title: "Contract", dataType: "string", editable:false, dataIndx: "ContractNo", minWidth: 70, maxWidth: 70, hidden: false, filter: {
type: "select",
condition: 'equal',
prepend: { '': '-ALL-' },
valueIndx: "ContractNo",
labelIndx: "ContractNo",
listeners: ['change']
}
},
{
title: "W.O", dataType: "string", dataIndx: "WorkOrderNumber", minWidth: 90, hidden: false, editable: function (ui) { if (ui.rowData.Update == 1) { return true; } else { return false; } },
filter: {
type: "select",
condition: 'equal',
prepend: { '': '-ALL-' },
valueIndx: "WorkOrderNumber",
labelIndx: "WorkOrderNumber",
listeners: ['change']
},
editor: {
type: 'select',
valueIndx: "WorkOrderNo",
labelIndx: "WorkOrderNo",
options: []
},
validations: [{ type: 'minLen', value: 1, msg: "Required" }]
},
{
title: "Event", dataType: "string", dataIndx: "Event", minWidth: 70, maxWidth: 70, hidden: false, editable: function (ui) { if (ui.rowData.Update == 1) { return true; } else { return false; } },
filter: {
type: "select",
condition: 'equal',
prepend: { '': '-ALL-' },
valueIndx: "Event",
labelIndx: "Event",
listeners: ['change']
},
editor: {
type: 'select',
prepend: { "": "" },
options: function (ui) {
var id = ui.rowData.WorkOrderNumber;
var eventList = "";
//iterate through the events list to find the matching record.
for (var i = 0; i < EventDD.length; i++) {
var row = EventDD;
if (row.WorkOrderNo == id) {//match found.
eventList = eventList + "|" + row.EventNo;
}
}
if (eventList.length == 0) {
return [];
}
else {
return eventList.split("|");
}
}
}
},
{
title: "S.I", dataType: "string", dataIndx: "SI", minWidth: 70, maxWidth: 80, hidden: false, editable: function (ui) { if (ui.rowData.Update == 1) { return true; } else { return false; } }, filter: {
type: "select",
condition: 'equal',
prepend: { '': '-ALL-' },
valueIndx: "SI",
labelIndx: "SI",
listeners: ['change']
},
editor: {
type: 'select',
prepend: { "": "" },
options: function (ui) {
var id = ui.rowData.WorkOrderNumber;
var SIList = "";
//iterate through the events list to find the matching record.
for (var i = 0; i < SIDD.length; i++) {
var row = SIDD;
if (row.VariationNo == id) {//match found.
SIList = SIList + "|" + row.SINo;
}
}
if (SIList.length == 0) {
return [];
}
else {
return SIList.split("|");
}
}
}
},
{
title: "SWS", dataType: "string", dataIndx: "SWS", minWidth: 70, maxWidth: 70, hidden: false, editable: function (ui) { if (ui.rowData.Update == 1) { return true; } else { return false; } }, filter: {
type: "select",
condition: 'equal',
prepend: { '': '-ALL-' },
valueIndx: "SWS",
labelIndx: "SWS",
listeners: ['change']
}
},
{
title: "Date", dataType: "date", dataIndx: "TimesheetDate", minWidth: 60, maxWidth: 60, hidden: false, editable: function (ui) { if (ui.rowData.Update == 1) { return true; } else { return false; } },
editor: {
type: 'textbox',
init: dateEditor
},
validations: [
{ type: 'regexp', value: '^[0-9]{2}/[0-9]{2}/[0-9]{2}$', msg: 'Not in dd/mm/yy format' }
]
},
{
title: "Comments", dataType: "string", dataIndx: "Comments", minWidth: 100, hidden: false, editable: function (ui) { if (ui.rowData.Update == 1) {return true;} else {return false;} }
},
{
title: "", dataIndx: "Delete", minWidth: 80, maxWidth: 80, hidden: false, editable: false,
render: function (ui) {
if (ui.rowData.Delete != null) {
if (ui.rowData.Delete == 1) {
return "<button type='button' class='delete_btn' style='font-weight: bold; color: #FF0000'>Delete</button>";
}
else {
return "<button type='button' disabled='disabled' style='font-weight: bold; color: #FFFFFF'>Delete</button>";
}
}
},
postRender: function (ui) {
var grid = this,
$cell = grid.getCell(ui);
$cell.find("button").button({ icons: { primary: 'ui-icon-scissors' } })
.bind("click", function () {
deleteRow(grid, ui.rowData.Employee, ui.rowData.EmployeeId, ui.rowData.WorkOrderNumber, ui.rowData.Event, ui.rowData.SI, ui.rowData.SWS, ui.rowData.TimesheetDate, ui.rowData.Comments, querySt('Login'));
});
}
},
{ title: "NT", dataType: "float", dataIndx: "NT", minWidth: 40, maxWidth: 40, editable: true },
{ title: "TH", dataType: "float", dataIndx: "TH", minWidth: 38, maxWidth: 38, editable: true },
{ title: "DT", dataType: "float", dataIndx: "DT", minWidth: 38, maxWidth: 38, editable: true },
{ title: "102", dataType: "float", dataIndx: "102", minWidth: 38, maxWidth: 38, editable: true },
{ title: "104", dataType: "float", dataIndx: "_104", minWidth: 38, maxWidth: 38, editable: true },
{ title: "105", dataType: "float", dataIndx: "_105", minWidth: 38, maxWidth: 38, editable: true },
{ title: "106", dataType: "float", dataIndx: "_106", minWidth: 38, maxWidth: 38, editable: true },
{ title: "107", dataType: "float", dataIndx: "_107", minWidth: 38, maxWidth: 38, editable: true },
{ title: "109", dataType: "float", dataIndx: "_109", minWidth: 38, maxWidth: 38, editable: true },
{ title: "110", dataType: "float", dataIndx: "_110", minWidth: 38, maxWidth: 38, editable: true },
{ title: "112", dataType: "float", dataIndx: "_112", minWidth: 38, maxWidth: 38, editable: true },
{ title: "113", dataType: "float", dataIndx: "_113", minWidth: 38, maxWidth: 38, editable: true },
{ title: "115", dataType: "float", dataIndx: "_115", minWidth: 38, maxWidth: 38, editable: true },
{ title: "120", dataType: "float", dataIndx: "_120", minWidth: 38, maxWidth: 38, editable: true },
{ title: "128", dataType: "float", dataIndx: "_128", minWidth: 38, maxWidth: 38, editable: true },
{ title: "129", dataType: "float", dataIndx: "_129", minWidth: 38, maxWidth: 38, editable: true },
{ title: "131", dataType: "float", dataIndx: "_131", minWidth: 38, maxWidth: 38, editable: true },
{ title: "132", dataType: "float", dataIndx: "_132", minWidth: 38, maxWidth: 38, editable: true },
{ title: "135", dataType: "float", dataIndx: "_135", minWidth: 38, maxWidth: 38, editable: true },
{ title: "140", dataType: "float", dataIndx: "_140", minWidth: 38, maxWidth: 38, editable: true },
{ title: "145", dataType: "float", dataIndx: "_145", minWidth: 38, maxWidth: 38, editable: true },
{ title: "146", dataType: "float", dataIndx: "_146", minWidth: 38, maxWidth: 38, editable: true },
{ title: "147", dataType: "float", dataIndx: "_147", minWidth: 38, maxWidth: 38, editable: true },
{ title: "148", dataType: "float", dataIndx: "_148", minWidth: 38, maxWidth: 38, editable: true },
{ title: "150", dataType: "float", dataIndx: "_150", minWidth: 38, maxWidth: 38, editable: true },
{ title: "151", dataType: "float", dataIndx: "_151", minWidth: 38, maxWidth: 38, editable: true },
{ title: "152", dataType: "float", dataIndx: "_152", minWidth: 38, maxWidth: 38, editable: true },
{ title: "155", dataType: "float", dataIndx: "_155", minWidth: 38, maxWidth: 38, editable: true },
{ title: "156", dataType: "float", dataIndx: "_156", minWidth: 38, maxWidth: 38, editable: true },
{ title: "160", dataType: "float", dataIndx: "_160", minWidth: 38, maxWidth: 38, editable: true },
{ title: "161", dataType: "float", dataIndx: "_161", minWidth: 38, maxWidth: 38, editable: true },
{ title: "161a", dataType: "float", dataIndx: "_161a", minWidth: 38, maxWidth: 38, editable: true },
{ title: "164", dataType: "float", dataIndx: "_164", minWidth: 38, maxWidth: 38, editable: true },
{ title: "168", dataType: "float", dataIndx: "_168", minWidth: 38, maxWidth: 38, editable: true },
{ title: "168a", dataType: "float", dataIndx: "_169a", minWidth: 38, maxWidth: 38, editable: true },
{ title: "170", dataType: "float", dataIndx: "_170", minWidth: 38, maxWidth: 38, editable: true },
{ title: "178", dataType: "float", dataIndx: "_178", minWidth: 38, maxWidth: 38, editable: true },
{ title: "180", dataType: "float", dataIndx: "_180", minWidth: 38, maxWidth: 38, editable: true },
{ title: "187", dataType: "float", dataIndx: "_187", minWidth: 38, maxWidth: 38, editable: true },
{ title: "188", dataType: "float", dataIndx: "_188", minWidth: 38, maxWidth: 38, editable: true },
{ title: "189", dataType: "float", dataIndx: "_189", minWidth: 38, maxWidth: 38, editable: true },
{ title: "196", dataType: "float", dataIndx: "_196", minWidth: 38, maxWidth: 38, editable: true },
{ title: "202", dataType: "float", dataIndx: "_202", minWidth: 38, maxWidth: 38, editable: true },
{ title: "210", dataType: "float", dataIndx: "_210", minWidth: 38, maxWidth: 38, editable: true },
{ title: "211", dataType: "float", dataIndx: "_211", minWidth: 38, maxWidth: 38, editable: true }
];