DHTML JavaScript Grid samples

Using Grid API Methods

Manipulate grid content, appearence and functionlity using wide range of Grid API methods

clearAll
setHeaderCol
copyRowContent (ex.:from first to selected)
clearSelection
setSelectedRow (ex.:second)
setEditable (ex.:on/off)
setUserData (ex.: to selected row)
getUserData (ex.: of selected row)
cells.getValue (ex.: of selected cell)
cells2.getValue (ex.: of selected cell)
moveRowDown (ex.:selected)
moveRowUp (ex.:selected)
getColumnCount
getRowsNum
getAllItemIds
isItemExists (with id=14)
setRowTextStyle (ex.:selected)
setRowTextBold (ex.:selected)
setRowTextNormal (ex.:selected)
setColumnIds (A,B)
getColumnId (ex.:first)
getColIndexById (ex.: B)
setRowId (ex.: selected)
getRowId (ex.:selected)
getRowIndex (ex.:selected)
getColWidth (ex.:of selected cell)
getSelectedCellIndex
getSelectedId
deleteSelectedItem
deleteRow (ex.: selected)
setMultiselect (on/off)
addRow (ex.:second position)
selectRow (ex.:first one)
selectCell (ex.: second cell of second row)
attachToObject

//...See Documentation for complete list of Grid API Methods and some details of their usage <a href="javascript:mygrid.clearAll()">clearAll</a><br> <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.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: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('x2','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>

Go to the dhtmlxGrid main page or Close this page