Validation with message

1st and 4th columns must be greater than 0, second and third columns not empty.
Update few rows and press "Update".

Add row

Remove Selected Row

</> Source
<!DOCTYPE html>
<html>
<head>
	<title>Validation with message</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, myDataProcessor;
		function doOnLoad(){
			// init grid and set its parameters (this part as always)
			myGrid = new dhtmlXGridObject('gridbox');
			myGrid.setImagePath("../../../codebase/imgs/");
			myGrid.setColumnIds("sales,book,author,price,store,shipping,best,date");
			myGrid.setHeader("Sales,Book Title,Author,Price,In Store,Shipping,Bestseller,Date of Publication");
			myGrid.setInitWidths("80,150,100,80,80,80,80,100");
			myGrid.setColAlign("right,left,left,right,center,left,center,center");
			myGrid.setColTypes("dyn,ed,txt,price,ch,coro,ch,ro");
			myGrid.setColSorting("int,str,str,int,str,str,str,date");
			myGrid.enableAutoWidth(true);
			myGrid.init();
			myGrid.load("php/get.php");	// used just for demo purposes
			//
			myDataProcessor = new dataProcessor("php/update.php"); // lock feed url
			myDataProcessor.setUpdateMode("off");
			myDataProcessor.setVerificator(0,greater_0);
			myDataProcessor.setVerificator(3,greater_0);
			myDataProcessor.setVerificator(1,not_empty);
			myDataProcessor.setVerificator(2,not_empty);
			myDataProcessor.attachEvent("onValidationError",function(id,messages){
				alert(messages.join("\n"));
				return true; // confirm block
			});
			myDataProcessor.init(myGrid); // link dataprocessor to the grid
		}
		function not_empty(value,id,ind){
			if (value=="")
				return "Value at ("+id+", "+ind+") can't be empty";
			return true;
		}
		function greater_0(value,id,ind){
			if (parseFloat(value)<=0)
				return "Value at ("+id+", "+ind+") must be greater than 0";
			return true;
		}	</script>
</head>
<body onload="doOnLoad()">
	<p>1st and 4th columns must be greater than 0, second and third columns not empty.<br />
	Update few rows and press "Update".</p>
	<div id="gridbox" style="width:750px;height:350px;overflow:hidden"></div>
	<p><a href="javascript:void(0)" onclick="myGrid.addRow((new Date()).valueOf(),[0,'','','',false,'na',false,''],myGrid.getRowIndex(myGrid.getSelectedId()))">Add row</a></p>
	<p><a href="javascript:void(0)" onclick="myGrid.deleteSelectedItem()">Remove Selected Row</a></p>
	<input type="button" name="some_name" value="update" onclick="myDataProcessor.sendData();">
</body>
</html>


Documentation

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