Using Grid API Methods
Manipulate grid content, appearance and functionality using wide range of Grid API methods
Manipulate grid content, appearance and functionality using wide range of Grid API methods
<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 width="400px" valign="top"> <div id="gridbox" style="width:360px;height:250px;"></div> </td> <td valign="top"> <div id="gridbox2" style="width:250px;height:250px;border:1px solid blue;overflow:auto"></div> </td> </tr> <tr> <td> <a href="javascript:mygrid.setHeaderCol(1,'New Header')">setHeaderCol</a><br> <a href="javascript:mygrid.copyRowContent(mygrid.getRowId(0),mygrid.getSelectedId())">copyRowContent (ex.:from first to selected)</a><br> <a href="javascript:mygrid.clearSelection()">clearSelection</a><br> <a href="javascript:mygrid.setSelectedRow(mygrid.getRowId(1))">setSelectedRow (ex.:second)</a><br> <a href="javascript:mygrid.setEditable(!mygrid.isEditable)">setEditable (ex.:on/off)</a><br> <a href="javascript:mygrid.setUserData(mygrid.getSelectedId(),'ud2','this value was set with script')">setUserData (ex.: to selected row)</a><br> <a href="javascript:alert(mygrid.getUserData(mygrid.getSelectedId(),'ud2'))">getUserData (ex.: of selected row)</a><br> <a href="javascript:alert(mygrid.cells(mygrid.getSelectedId(),mygrid.getSelectedCellIndex()).getValue())">cells.getValue (ex.: of selected cell)</a><br> <a href="javascript:alert(mygrid.cells2(mygrid.getRowIndex(mygrid.getSelectedId()),mygrid.getSelectedCellIndex()).getValue())">cells2.getValue (ex.: of selected cell)</a><br> <a href="javascript:mygrid.moveRowDown(mygrid.getSelectedId())">moveRowDown (ex.:selected)</a><br> <a href="javascript:mygrid.moveRowUp(mygrid.getSelectedId())">moveRowUp (ex.:selected)</a><br> <a href="javascript:alert(mygrid.getColumnCount())">getColumnCount</a><br> <a href="javascript:alert(mygrid.getRowsNum())">getRowsNum</a><br> <a href="javascript:alert(mygrid.getAllItemIds())">getAllItemIds</a><br> <a href="javascript:alert(mygrid.isItemExists('14'))">isItemExists (with id=14)</a><br> <a href="javascript:mygrid.setRowTextStyle(mygrid.getSelectedId(),'color:red;font-family:verdana;font-size:14px;')">setRowTextStyle (ex.:selected)</a><br> <a href="javascript:mygrid.setRowTextBold(mygrid.getSelectedId())">setRowTextBold (ex.:selected)</a><br> <a href="javascript:mygrid.setRowTextNormal(mygrid.getSelectedId())">setRowTextNormal (ex.:selected)</a><br> <a href="javascript:mygrid.clearAll()">clearAll</a><br> </td> <td> <a href="javascript:mygrid.setColumnIds('A,B')">setColumnIds (A,B)</a><br> <a href="javascript:alert(mygrid.getColumnId(0))">getColumnId (ex.:first)</a><br> <a href="javascript:alert(mygrid.getColIndexById('B'))">getColIndexById (ex.: B)</a><br> <a href="javascript:mygrid.setRowId(mygrid.getRowIndex(mygrid.getSelectedId()),'newid')">setRowId (ex.: selected)</a><br> <a href="javascript:alert(mygrid.getRowId(mygrid.getRowIndex(mygrid.getSelectedId())))">getRowId (ex.:selected)</a><br> <a href="javascript:alert(mygrid.getRowIndex(mygrid.getSelectedId()))">getRowIndex (ex.:selected)</a><br> <a href="javascript:alert(mygrid.getColWidth(mygrid.getSelectedCellIndex()))">getColWidth (ex.:of selected cell)</a><br> <a href="javascript:alert(mygrid.getSelectedCellIndex())">getSelectedCellIndex</a><br> <a href="javascript:alert(mygrid.getSelectedId())">getSelectedId</a><br> <a href="javascript:mygrid.deleteSelectedItem()">deleteSelectedItem</a><br> <a href="javascript:void(0)" onclick="mygrid.deleteRow(mygrid.getSelectedId())">deleteRow (ex.: selected)</a><br> <a href="javascript:mygrid.setMultiselect(!mygrid.selMultiRows)">setMultiselect (on/off)</a><br> <a href="javascript:void(mygrid.addRow(mygrid.getUID(),'text 1,text 2',1))">addRow (ex.:second position)</a><br> <a href="javascript:mygrid.selectRow(0)">selectRow (ex.:first one)</a><br> <a href="javascript:mygrid.selectCell(1,1)">selectCell (ex.: second cell of second row)</a><br> <a href="javascript:mygrid.attachToObject(document.getElementById('gridbox2'))">attachToObject</a><br> </td> </tr> </table> <script></script>mygrid = new dhtmlXGridObject('gridbox'); mygrid.setImagePath("../../codebase/imgs/"); mygrid.setHeader("Column A, Column B"); mygrid.setInitWidths("100,250"); mygrid.setColAlign("right,left"); mygrid.setColTypes("dyn,ed"); mygrid.setColSorting("str,str"); mygrid.init(); mygrid.setSkin("dhx_skyblue"); mygrid.loadXML("../common/grid_16_rows_columns_manipulations.xml", function() { mygrid.selectRow(1); });