Move row by API

dhmlxGrid allows you to manipulate rows from API using moveRow method.



   
</> Source
<!DOCTYPE html>
<!--pro-->
<html>
<head>
	<title>Move row by API</title>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
	<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
	<link rel="stylesheet" type="text/css" href="../../../codebase/fonts/font_roboto/roboto.css"/>
	<link rel="stylesheet" type="text/css" href="../../../codebase/dhtmlx.css"/>
	<script src="../../../codebase/dhtmlx.js"></script>
	<script>
		var myGrid, myGrid2;
		function doOnLoad(){
			myGrid = new dhtmlXGridObject('gridbox');
			buildGrid(myGrid);
			myGrid2 = new dhtmlXGridObject('gridbox2');
			buildGrid(myGrid2);
		}
		function buildGrid(grid){
			grid.setImagePath("../../../codebase/imgs/");
			grid.setHeader("Sales,Book Title,Author,Price,In Store,Shipping,Bestseller,Date of Publication");
			grid.setInitWidths("75,130,120,70,70,70,70,100");
			grid.setColAlign("right,left,left,right,center,left,center,center");
			grid.setColTypes("dyn,ed,ed,price,ch,co,ra,ro");
			var combobox = grid.getCombo(5);
			combobox.put("1","1 Hour");
			combobox.put("12","12 Hours");
			combobox.put("24","24 Hours");
			combobox.put("48","2 days");
			combobox.put("168","1 week");
			combobox.put("pick","pick up");
			combobox.put("na","na");
			grid.setColSorting("int,str,str,int,str,str,str,date");
			grid.enableAutoWidth(true);
			grid.enableAutoHeight(true);
			grid.init();
			grid.load("../common/grid_16_rows_columns_manipulations.xml");
		}
	</script>
</head>
<body onload="doOnLoad()">
	<h1>Move row by API</h1>
	<p>dhmlxGrid allows you to manipulate rows from API using moveRow method.</p>
	<table width="900">
		<tr>
			<td>
				<div id="gridbox" style="width:600px;height:450px;background-color:white;"></div>
			</td>
			<td>
				<div><a href='#' onclick='myGrid.moveRow(myGrid.getSelectedId(),"up")'>Move selected row up</a></div>
				<div><a href='#' onclick='myGrid.moveRow(myGrid.getSelectedId(),"down")'>Move selected  row down</a></div>
				<div><a href='#' onclick='if (myGrid.getSelectedId()) myGrid.moveRow(myGrid.getSelectedId(),"row_sibling",myGrid2.getSelectedId(),myGrid2)'>Move selected  row after selected row in grid [2]</a></div>
			</td>
		</tr>
		<tr>
		<td><br></td>
		<td><br></td>
		</tr>
		<tr>
			<td>
				<div id="gridbox2" style="width:600px;height:450px;background-color:white;"></div>
			</td>
			<td>
				<div><a href='#' onclick='myGrid2.moveRow(myGrid2.getSelectedId(),"up")'>Move selected row up</a></div>
				<div><a href='#' onclick='myGrid2.moveRow(myGrid2.getSelectedId(),"down")'>Move selected  row down</a></div>
				<div><a href='#' onclick='if (myGrid2.getSelectedId()) myGrid2.moveRow(myGrid2.getSelectedId(),"row_sibling",myGrid.getSelectedId(),myGrid)'>Move selected  row after selected row in grid [1]</a></div>
			</td>
		</tr>
		<tr>
			<td>&nbsp;</td>
			<td>&nbsp;</td>
		</tr>
	</table>
</body>
</html>

Documentation

Check documentation to learn how to use the components and easily implement them in your applications.