DHTMLX Docs & Samples Explorer

Set sorting image state

You can set sorting image state (ascendant/descendant) for any column in you grid. Moreover you are allowed to control its visibility by showing or hiding sorting image.

 Show sorting image
 Hide sorting image

Source
<link rel="STYLESHEET" type="text/css" href="../../codebase/dhtmlxgrid.css">
<link rel="stylesheet" type="text/css" href="../../codebase/skins/dhtmlxgrid_dhx_skyblue.css">
<script  src="../../codebase/dhtmlxcommon.js"></script>
<script  src="../../codebase/dhtmlxgrid.js"></script>        
<script  src="../../codebase/dhtmlxgridcell.js"></script>
 
 
 
 
<table width="600px">
  <tr>
        <td>
            <div id="gridbox" style="width:100%;height:270px;background-color:white;"></div>
        </td>
    </tr>
    <tr>
        <td>
            &nbsp;<a href='#' onclick='mygrid.setSortImgState(true,this.nextSibling.nextSibling.value,this.nextSibling.value)'>Show sorting image</a><select><option value='ASC'>ASC</option><option value='DESC'>DESC</option></select><select><option value="0">Column 0</option><option value="1">Column 1</option></select>
            <br/>
            &nbsp;<a href='#' onclick='mygrid.setSortImgState(false)'>Hide sorting image</a>
        </td>
    </tr>
</table>
<br>
 
<script>
mygrid = new dhtmlXGridObject('gridbox');
mygrid.setImagePath("../../codebase/imgs/");
mygrid.setHeader("Sales,Book Title,Author,Price,In Store,Shipping,Bestseller,Date of Publication");
mygrid.setInitWidths("50,150,100,80,80,80,80,200");
mygrid.setColAlign("right,left,left,right,center,left,center,center");
mygrid.setColTypes("dyn,ed,ed,price,ch,co,ra,ro");
mygrid.getCombo(5).put(2, 2);
mygrid.setColSorting("int,str,str,int,str,str,str,date");
mygrid.init();
mygrid.setSkin("dhx_skyblue");
mygrid.loadXML("../common/grid_16_rows_columns_manipulations.xml");
</script>