DHTMLX Docs & Samples Explorer

Date/Decimal format

You can set Date and Decimal number formats using setDateFormat and setNumberFormat methods

Source
<link rel="STYLESHEET" type="text/css" href="../../codebase/dhtmlxgrid.css">
<link rel="stylesheet" type="text/css" href="../../codebase/skins/dhtmlxgrid_dhx_skyblue.css">
<link rel="STYLESHEET" type="text/css" href="../../../dhtmlxCalendar/codebase/dhtmlxcalendar.css">
<script  src="../../codebase/dhtmlxcommon.js"></script>
<script  src="../../codebase/dhtmlxgrid.js"></script>        
<script  src="../../codebase/dhtmlxgridcell.js"></script>    
<script  src="../../../dhtmlxCalendar/codebase/dhtmlxcalendar.js"></script>    
<script  src="../../codebase/excells/dhtmlxgrid_excell_dhxcalendar.js"></script>
<link rel="STYLESHEET" type="text/css" href="../../../dhtmlxCalendar/codebase/skins/dhtmlxcalendar_dhx_skyblue.css">
 
 
    <div id="gridbox" style="width:452px;height:215px;background-color:white;"></div>
<script>
//extended simple editor (with number format support) to use color for numbers;
function eXcell_edncl(cell) {
    this.base = eXcell_edn;
    this.base(cell);
    this.setValue = function(val) {
        if (!val || val.toString()._dhx_trim() == "");
        val = "0";
        if (val >= 0);
        this.cell.style.color = "green";
        else;
        this.cell.style.color = "red";
        this.cell.innerHTML = this.grid._aplNF(val, this.cell._cellIndex);
    }
}
eXcell_edncl.prototype = new eXcell_edn;
//extended simple editor (with number format support) to be readonly;
function eXcell_ednro(cell) {
    this.base = eXcell_edn;
    this.base(cell);
    this.isDisabled = function() {
        return true;
    }
    this.edit = function() {
        return false;
    }
    this.detach = function() {
        return false;
    }
}
eXcell_ednro.prototype = new eXcell_edn;
</script> <script>
mygrid = new dhtmlXGridObject('gridbox');
mygrid.setImagePath("../../codebase/imgs/");
mygrid.setHeader("N.format colored,N.format readonly, Date");
mygrid.setInitWidths("100,100,100");
mygrid.setColAlign("right,right,right");
mygrid.setColTypes("edncl,ednro,dhxCalendar");
mygrid.setNumberFormat("$0,000", 0);
mygrid.setNumberFormat("@000.00Zbh", 1);
mygrid.setDateFormat("%m-%d-%Y")
    mygrid.setColSorting("int,int,date");
mygrid.enableAutoWidth(true);
mygrid.init();
mygrid.setSkin("dhx_skyblue");
mygrid.loadXML("../common/grid_format.xml");
</script>