DHTMLX Grid per default uses 0 for unchecked column all other for checked.
In my Data this is Y/N, how can i handle this in an mostly DHTMLX like way ?
The only solution is to customize the current “ch” column type.
Here you can find a tutorial:
docs.dhtmlx.com/grid__columns_t … olumntypes
and some sot of the example:
function eXcell_NY_ch(cell){ //the eXcell name is defined here
if (cell){ //the default pattern, just copy it
this.cell = cell;
this.grid = this.cell.parentNode.grid;
eXcell_ch.call(this); //uses methods of the "ch" type
}
this.setValue=function(val){
this.cell.style.verticalAlign="middle";
if (val=="Y"){
this.cell.chstate="1";
} else {
val="N";
this.cell.chstate="0"
}
var obj = this;
this.cell.setAttribute("excell", "ch");
if (val=="Y")
state=1
else
state=0
this.setCValue("<img src='"+this.grid.imgURL+"item_chk"+state
+".gif' onclick='new eXcell_ch(this.parentNode).changeState(true); (arguments[0]||event).cancelBubble=true; '>",
this.cell.chstate);
}
}
eXcell_NY_ch.prototype = new eXcell
Tkanks for your reply, that looks good.
But it works at time not for me. The functions gets never called.
I call your code long before the grid is created as far as i understand should this then work for all grids. Exactly my needs.
But it seems to do nothing. Do i have to use another cell name than “ch” ?
oh, my bad.
Please, try to use “NY_ch” column type.
i dont get it.
TypeError: s is undefined
Stack-Trace:
dhtmlXGridObject.prototype._dp_init/a._getRowData@file:///C:/Quellen/promet-app-tasks-dx/codebase/dhtmlx.js:9:842332
dataProcessor.prototype.sendData@file:///C:/Quellen/promet-app-tasks-dx/codebase/dhtmlx.js:9:1360388
dataProcessor.prototype.setUpdated@file:///C:/Quellen/promet-app-tasks-dx/codebase/dhtmlx.js:9:1359320
dhtmlXGridObject.prototype._dp_init/<@file:///C:/Quellen/promet-app-tasks-dx/codebase/dhtmlx.js:9:842005
window.dhx4._eventable/a.callEvent@file:///C:/Quellen/promet-app-tasks-dx/codebase/dhtmlx.js:9:19307
dhtmlXGridObject.prototype.addRow@file:///C:/Quellen/promet-app-tasks-dx/codebase/dhtmlx.js:9:832474
newPrometDataStore/aDS.FillGrid/<@file:///C:/Quellen/promet-app-tasks-dx/appbase/promet-datastore.js:38:11
LoadData/<.callback@file:///C:/Quellen/promet-app-tasks-dx/appbase/promet.js:153:13
window.dhx4.ajax._call/n.onreadystatechange/<@file:///C:/Quellen/promet-app-tasks-dx/codebase/dhtmlx.js:9:15062
promet-datastore.js:44:9
I have also tried to change the setValue funtion from ch type since i find it cleaner to use the standard cell type
eXcell_ch.prototype.setValue = function(val) {
this.cell.style.verticalAlign="middle";
if ((val=="Y")||(val==1)){
val="Y";
this.cell.chstate="1";
} else {
val="N";
this.cell.chstate="0";
}
var obj = this;
this.cell.setAttribute("excell", "ch");
if (val=="Y")
state=1
else
state=0
this.setCValue("<img src='"+this.grid.imgURL+"item_chk"+state
+".gif' onclick='new eXcell_ch(this.parentNode).changeState(true); (arguments[0]||event).cancelBubble=true; '>",
this.cell.chstate);
}
But this seems to work only for adding Data programmatically. In Dataprocessor the value is always 0/1
Ah thers an getValue function also
Great, then all works now (Ive changed get/setValue from ch columntype so i dont have to use an own Type). Thanks.
I have the same Problem on another row.
I want to exchange other values (Displayed in grid other than in Datasource)
But it crashes with “TypeError: s is undefined”
And this callstack:
dhtmlXGridObject.prototype._dp_init/a._getRowData file:///C:/Quellen/promet-app-times-dx/codebase/dhtmlx.js:9:842332
dataProcessor.prototype.sendData file:///C:/Quellen/promet-app-times-dx/codebase/dhtmlx.js:9:1360388
dataProcessor.prototype.setUpdated file:///C:/Quellen/promet-app-times-dx/codebase/dhtmlx.js:9:1359320
dhtmlXGridObject.prototype._dp_init/< file:///C:/Quellen/promet-app-times-dx/codebase/dhtmlx.js:9:842005
window.dhx4._eventable/a.callEvent file:///C:/Quellen/promet-app-times-dx/codebase/dhtmlx.js:9:19307
dhtmlXGridObject.prototype.addRow
I found out that this only happens with Dataprocessor assigned to the Grid (when i dont call Dataprocessor.init(myGrid) it dont happend)
And only with custom Column Types.
Has anybody an idea what can causes this
Could you please, provide with a complete demo or a demo link where the problem can be reconstructed or with sample of your code including the custom exCell.