I am a non commercial user. I have tried read only for particular column with conditions while doing search options , The readonly options is not working and not applicable all times this conditions …
can you help me out how to resolve this issues.
Code :
var table_settings = {
data: dataobject,
columns: cols,
stretchH: ‘all’,
search: {
queryMethod: onlyExactMatch1,
searchResultClass: ‘searchClass’
},
autoWrapRow: true,
rowHeaders: true,
formulas: true,
observeChanges: false,
colHeaders: [
],
cells: function (row, col, prop) {
var cellProperties = {
readOnly: false
};
var hot = this.instance;
var refId = hot.getDataAtCell(row, hot.colToProp(0))
var date = null;
date = hot.getDataAtCell(row, hot.colToProp(4));
var fullDate = new Date()
var twoDigitMonth = ((fullDate.getMonth().length+1) === 1)? (fullDate.getMonth()+1) : '0' + (fullDate.getMonth()+1);
var currentDate = twoDigitMonth + “-” + fullDate.getDate() + “-” + fullDate.getFullYear();
var date1 = new Date(date);
var date2 = new Date(currentDate);
// To calculate the time difference of two dates
var Difference_In_Time = date2.getTime() - date1.getTime();
// To calculate the no. of days between two dates
var Difference_In_Days = Difference_In_Time / (1000 * 3600 * 24);
if(Difference_In_Days >= 30) {
console.log(Difference_In_Days,date,row,"read only",col,hot.getDataAtCell(row, hot.colToProp(0)));
cellProperties.readOnly = true;
} else {
console.log(Difference_In_Days,date,row,"Else",col,hot.getDataAtCell(row, hot.colToProp(0)));
}
} }
return cellProperties;
},