how to avoid multiple posts after adding record to 2nd grid

When I add a grade for the selected marker (from first grid), why is it sending more than one post to the server? I found out that the more markers I selected, the more posts are sent.

Here is my source code:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<style>
	html, body 
	{
		width: 100%;
		height: 100%;
		margin: 0px;
		overflow: auto;
		background-color: red;
	}
	</style>

	<!--  Common --> 
	<script type="text/javascript" src="/dhx/dhtmlxGrid/codebase/dhtmlxcommon.js"></script>

	<!--  Grid  -->
	<script type="text/javascript" src="/dhx/dhtmlxGrid/codebase/dhtmlxgrid.js"></script>
	<script type="text/javascript" src="/dhx/dhtmlxGrid/codebase/dhtmlxgridcell.js"></script>
	<script type="text/javascript" src="/dhx/dhtmlxGrid/codebase/ext/dhtmlxgrid_srnd.js"></script>
	<link rel="stylesheet" type="text/css" href="/dhx/dhtmlxGrid/codebase/dhtmlxgrid.css">    
	<link rel="stylesheet" type="text/css" href="/dhx/dhtmlxGrid/codebase/skins/dhtmlxgrid_dhx_blue.css">
	<link rel="stylesheet" type="text/css" href="/dhx/dhtmlxGrid/codebase/skins/dhtmlxgrid_dhx_black.css">
	<link rel="stylesheet" type="text/css" href="/dhx/dhtmlxGrid/codebase/skins/dhtmlxgrid_dhx_skyblue.css">


	<!--  Layout  -->
	<script type="text/javascript" src="/dhx/dhtmlxLayout/codebase/dhtmlxlayout.js"></script>
	<script type="text/javascript" src="/dhx/dhtmlxLayout/codebase/dhtmlxcontainer.js"></script>
	<link rel="stylesheet" type="text/css" href="/dhx/dhtmlxLayout/codebase/dhtmlxlayout.css">
	<link rel="stylesheet" type="text/css" href="/dhx/dhtmlxLayout/codebase/skins/dhtmlxlayout_dhx_blue.css">
	<link rel="stylesheet" type="text/css" href="/dhx/dhtmlxLayout/codebase/skins/dhtmlxlayout_dhx_black.css">
	<link rel="stylesheet" type="text/css" href="/dhx/dhtmlxLayout/codebase/skins/dhtmlxlayout_dhx_skyblue.css">

	<!--  Tabbar  -->
	<script type="text/javascript" src="/dhx/dhtmlxTabbar/codebase/dhtmlxcommon.js"></script>
	<script type="text/javascript" src="/dhx/dhtmlxTabbar/codebase/dhtmlxtabbar.js"></script>
	<link rel="stylesheet" type="text/css" href="/dhx/dhtmlxTabbar/codebase/dhtmlxtabbar.css">

	<!--  Toolbar  -->
	<script type="text/javascript" src="/dhx/dhtmlxToolbar/codebase/dhtmlxtoolbar.js"></script>
	<link rel="stylesheet" type="text/css" href="/dhx/dhtmlxToolbar/codebase/skins/dhtmlxtoolbar_dhx_blue.css">
	<link rel="stylesheet" type="text/css" href="/dhx/dhtmlxToolbar/codebase/skins/dhtmlxtoolbar_dhx_black.css">
	<link rel="stylesheet" type="text/css" href="/dhx/dhtmlxToolbar/codebase/skins/dhtmlxtoolbar_dhx_skyblue.css">

	<script type="text/javascript" src="/dhx/dhtmlxGrid/codebase/ext/dhtmlxgrid_drag.js"></script>
	<script type="text/javascript" src="/dhx/dhtmlxGrid/codebase/ext/dhtmlxgrid_filter.js"></script>
	<script type="text/javascript" src="/dhx/dhtmlxGrid/codebase/ext/dhtmlxgrid_keymap_access.js"></script>
	<script type="text/javascript" src="/dhx/dhtmlxGrid/codebase/ext/dhtmlxgrid_keymap_excel.js"></script>
	<script type="text/javascript" src="/dhx/dhtmlxGrid/codebase/ext/dhtmlxgrid_keymap_extra.js"></script>
	<script type="text/javascript" src="/dhx/dhtmlxGrid/codebase/ext/dhtmlxgrid_nxml.js"></script>
	<script type="text/javascript" src="/dhx/dhtmlxGrid/codebase/ext/dhtmlxgrid_selection.js"></script>
	<script type="text/javascript" src="/dhx/dhtmlxGrid/codebase/ext/dhtmlxgrid_start.js"></script>
	<script type="text/javascript" src="/dhx/dhtmlxGrid/codebase/ext/dhtmlxgrid_validation.js"></script>

	<!--  Dataprocessor  -->
	<script type="text/javascript" src="/dhx/dhtmlxDataProcessor/codebase/dhtmlxdataprocessor.js"></script>

	<!--  Connector -->
	<script type="text/javascript" src="/dhx/dhtmlxConnector/codebase/connector.js"></script>

	<script type="text/javascript" >
	// global variables
	var dhxGrid = null, dhxLayout = null, dhxToolbar = null, dhxTabbar = null;
	var gridContact = null, contactToolbar = null, dpContact=null;
	var gridAccommodation = null, accommodationToolbar = null, dpAccommodation = null;
	var gridGrades = null, gradesToolbar = null, dpGrades=null;
	var dpMarker = null;
	var g_marker_id, idMarkerEvent, idTabEvent; 

	function doOnload() {
		// -- Layout Menu
		dhxLayout = new dhtmlXLayoutObject(document.body, "2E", "dhx_skyblue");

		// -- Layout Grid
		dhxLayout.cells("a").setText("Markers");
		dhxLayout.cells("b").hideHeader();
		markerGrid();		
	}
	function markerGrid() {
		// -- Layout Grid attachToolbar
		if (dhxToolbar == null) {
			dhxToolbar = dhxLayout.cells("a").attachToolbar();
			dhxToolbar.addButton("btn_add",  1, "Add");
			dhxToolbar.addSeparator("sep", 2);            
			dhxToolbar.addButton("btn_del",  3, "Delete");
			dhxToolbar.addSeparator("sep", 4);
			dhxToolbar.addButton("btn_edit", 5, "Edit");
			dhxToolbar.base.onclick=function(e){e=e||event;e.cancelBubble=true;};

			dhxToolbar.attachEvent("onClick", function(id) {
				if (id == "btn_add") {
					var idd=dhxGrid.uid(); 
					dhxGrid.addRow(idd,'',0); 
					dhxGrid.showRow(idd);
				}
				if (id == "btn_del") {
					dhxGrid.deleteSelectedRows();
				}
				if (id == "btn_edit") {
					dhxGrid.editCell();				
				}
			});
		}

		// -- Layout Grid attachGrid
		if (dhxGrid == null) {
			dhxGrid = dhxLayout.cells("a").attachGrid();
			dhxGrid.setImagePath("/dhx/dhtmlxGrid/codebase/imgs/");
			dhxGrid.setHeader("Name, Address, City, Province, Zip code, Phone");
			dhxGrid.setInitWidths("300,*");
			dhxGrid.enableAutoWidth(true);
			dhxGrid.setColTypes("ed,ed,ed,coro,ed,ed");	
		dhxGrid.attachHeader("#connector_text_filter,#connector_text_filter,#connector_text_filter,#connector_select_filter,#connector_text_filter,#connector_text_filter");
			dhxGrid.setColSorting("str,str,str,str,str,str");
			dhxGrid.enableSmartRendering(true);

			idMarkerEvent = dhxGrid.attachEvent("onRowSelect", markerSelected);
			dhxGrid.init();
		}
		dhxGrid.clearAll();
		dhxGrid.loadXML("connector_marker.php");		

		dpMarker = new dataProcessor("connector_marker.php");
		dpMarker.init(dhxGrid);	

		if (dhxTabbar == null) {
			dhxTabbar = dhxLayout.cells("b").attachTabbar();
			dhxTabbar.setImagePath("/dhx/dhtmlxTabbar/codebase/imgs/");
			dhxTabbar.setSkin("modern");
			dhxTabbar.addTab("a1", "Accommodations", "130px");
			dhxTabbar.addTab("a2", "Contacts", "100px");
			dhxTabbar.addTab("a3", "Grades", "100px");

			idTabEvent = dhxTabbar.attachEvent("onSelect", "tabSelected");
			dhxTabbar.setTabActive("a1");
		}
	}	

	function accommodation() {
		if (accommodationToolbar == null) {
			accommodationToolbar = dhxTabbar.cells("a1").attachToolbar();
			accommodationToolbar.setSkin("dhx_skyblue");			
			accommodationToolbar.addButton("btn_add",  1, "Add");
			accommodationToolbar.addSeparator("sep", 2);            
			accommodationToolbar.addButton("btn_del",  3, "Delete");
			accommodationToolbar.addSeparator("sep", 4);
			accommodationToolbar.addButton("btn_edit", 5, "Edit");
			accommodationToolbar.base.onclick=function(e){e=e||event;e.cancelBubble=true;};
			accommodationToolbar.attachEvent("onClick", function(id) {
				if (id == "btn_add") {
					var idd=gridAccommodation.uid(); 
					gridAccommodation.addRow(idd,'',0); 
					gridAccommodation.showRow(idd);
				}
				if (id == "btn_del") {
					gridAccommodation.deleteSelectedRows();
				}
				if (id == "btn_edit") {
					gridAccommodation.editCell();
				}
				return true;
			});
		}

		if (gridAccommodation == null) {
			gridAccommodation = dhxTabbar.cells("a1").attachGrid();
			gridAccommodation.setImagePath("/dhx/dhtmlxGrid/codebase/imgs/");
			gridAccommodation.setSkin("dhx_skyblue");
			gridAccommodation.setHeader("Accommodation Type,# Rooms,Description,Date");
			gridAccommodation.setInitWidths("150,60,*,80");
			gridAccommodation.enableAutoWidth(true);
			gridAccommodation.enableSmartRendering(true);
			gridAccommodation.setColTypes("coro,ed,ed,ed");	
		gridAccommodation.attachHeader("#connector_select_filter,&nbsp;,#connector_text_filter,&nbsp;");
			gridAccommodation.setColSorting("str,str,str,str");
			gridAccommodation.setColValidators("NotEmpty,ValidInteger,,ValidDate");
			gridAccommodation.init();			
		}
		gridAccommodation.clearAll();	
	gridAccommodation.loadXML("connector_accommodation.php?marker_id="+g_marker_id);
		dpAccommodation = new dataProcessor("connector_accommodation.php?marker_id="+g_marker_id);
		dpAccommodation.init(gridAccommodation);
		//dpAccommodation.enablePartialDataSend(true);
	}	

	function contact() {
		if (contactToolbar == null) {
			contactToolbar = dhxTabbar.cells("a2").attachToolbar();
			contactToolbar.setSkin("dhx_skyblue");			
			contactToolbar.addButton("btn_add",  1, "Add");
			contactToolbar.addSeparator("sep", 2);            
			contactToolbar.addButton("btn_del",  3, "Delete");
			contactToolbar.addSeparator("sep", 4);
			contactToolbar.addButton("btn_edit", 5, "Edit");
			contactToolbar.base.onclick=function(e){e=e||event;e.cancelBubble=true;};
			contactToolbar.attachEvent("onClick", function(id) {
				if (id == "btn_add") {
					var idd=gridContact.uid(); 
					gridContact.addRow(idd,'',0); 
					gridContact.showRow(idd);
				}
				if (id == "btn_del") {
					gridContact.deleteSelectedRows();
				}
				if (id == "btn_edit") {
					gridContact.editCell();
				}
				return true;
			});	
		}
		if (gridContact == null) {
			gridContact = dhxTabbar.cells("a2").attachGrid();
			gridContact.setImagePath("/dhx/dhtmlxGrid/codebase/imgs/");
			gridContact.setSkin("dhx_skyblue");
			gridContact.setHeader("Title,First Name,Last Name,Suffix,Phone,Fax,Pager,Mobile,E-mail,Note(s),Contact Type");

			gridContact.setInitWidths("75,120,120,75,90,90,90,90,*,100,150");
			gridContact.enableAutoWidth(true);
			gridContact.enableSmartRendering(true);	
			gridContact.setColTypes("ed,ed,ed,ed,ed,ed,ed,ed,ed,ed,coro");	
	gridContact.attachHeader("&nbsp;,#connector_text_filter,#connector_text_filter,&nbsp;,#connector_text_filter,&nbsp;,&nbsp;,#connector_text_filter,#connector_text_filter,#connector_text_filter,#connector_select_filter");

			gridContact.setColSorting("str,str,str,str,str,str,str,str,str,str,str");
			gridContact.init();
		}
		gridContact.clearAll();
		gridContact.loadXML("connector_contact.php?marker_id="+g_marker_id);
		dpContact = new dataProcessor("connector_contact.php?marker_id="+g_marker_id);
		dpContact.init(gridContact);
		//dpContact.enablePartialDataSend(true);
	}

	function grades() {
		if (gradesToolbar == null) {
			gradesToolbar = dhxTabbar.cells("a3").attachToolbar();
			gradesToolbar.setSkin("dhx_skyblue");			
			gradesToolbar.addButton("btn_add",  1, "Add");
			gradesToolbar.addSeparator("sep", 2);            
			gradesToolbar.addButton("btn_del",  3, "Delete");
			gradesToolbar.addSeparator("sep", 4);
			gradesToolbar.addButton("btn_edit", 5, "Edit");
			gradesToolbar.base.onclick=function(e){e=e||event;e.cancelBubble=true;};
			gradesToolbar.attachEvent("onClick", function(id) {

				if (id == "btn_add") {
					var idd=gridGrades.uid(); 
					gridGrades.addRow(idd,'10,',0); 
					gridGrades.showRow(idd);
				}

				if (id == "btn_del") {
					gridGrades.deleteSelectedRows();
				}
				if (id == "btn_edit") {
					gridGrades.editCell();
				}
				return true;
			});	
		}

		if (gridGrades == null)	{
			gridGrades = dhxTabbar.cells("a3").attachGrid();
			gridGrades.setImagePath("/dhx/dhtmlxGrid/codebase/imgs/");

			gridGrades.setSkin("dhx_skyblue");
			gridGrades.setHeader("Score,to Grade");
			gridGrades.setInitWidths("75,*");
			gridGrades.enableAutoWidth(true);
			gridGrades.enableSmartRendering(true);	

			gridGrades.setColTypes("ed,coro");	
			gridGrades.attachHeader("&nbsp;,#connector_select_filter");
			gridGrades.setColSorting("str,str");
			gridGrades.init();
		}
		gridGrades.clearAll();
		gridGrades.loadXML("connector_grades.php?marker_id="+g_marker_id);

		dpGrades = new dataProcessor("connector_grades.php?marker_id="+g_marker_id);
		dpGrades.init(gridGrades);
		//dpGrades.enablePartialDataSend(true);
	}	

	function markerSelected (marker_id) {
		g_marker_id = marker_id;	

		if (dhxTabbar.getActiveTab() != null) {
			getActiveTab(dhxTabbar.getActiveTab())
		}
	}
	function tabSelected(id, last_id) {
		//dhxGrid.detachEvent(idMarkerEvent);

		getActiveTab(id);
		
		//idMarkerEvent = dhxGrid.attachEvent("onRowSelect", markerSelected);
		return true;
	}
	function getActiveTab(id) {
		switch (id) {
			case "a1" : accommodation();	break;
			case "a2" : contact();		break;
			case "a3" : grades();		break;
		}
	}
	</script>

</head>
<body onload="doOnload();">
</body>
</html>

Here is the output from firebug, it should only once call connector_grades.php:

GET http://tiger/lt2/connector_marker.php?connector=true&dhx_colls=3 200 OK 187ms dhtmlxcommon.js (regel 203)
GET http://tiger/lt2/connector_accommodation.php?marker_id=undefined&connector=true&dhx_colls=0,3 200 OK 159ms dhtmlxcommon.js (regel 203)
GET http://tiger/lt2/connector_accommodation.php?marker_id=4 200 OK 54ms dhtmlxcommon.js (regel 203)
GET http://tiger/lt2/connector_contact.php?marker_id=4&connector=true&dhx_colls=10 200 OK    72ms dhtmlxcommon.js (regel 203)
GET http://tiger/lt2/connector_grades.php?marker_id=4&connector=true&dhx_colls=1 200 OK   69ms dhtmlxcommon.js (regel 203)
GET http://tiger/lt2/connector_contact.php?marker_id=4 200 OK 62ms dhtmlxcommon.js (regel 203)
GET http://tiger/lt2/connector_grades.php?marker_id=4 200 OK 67ms dhtmlxcommon.js (regel 203)
GET http://tiger/lt2/connector_contact.php?marker_id=4 200 OK 59ms dhtmlxcommon.js (regel 203)
GET http://tiger/lt2/connector_accommodation.php?marker_id=4 200 OK 68ms dhtmlxcommon.js (regel 203)
GET http://tiger/lt2/connector_grades.php?marker_id=4 200 OK 54ms dhtmlxcommon.js (regel 203)
GET http://tiger/lt2/connector_grades.php?marker_id=3 200 OK 54ms dhtmlxcommon.js (regel 203)
GET http://tiger/lt2/connector_grades.php?marker_id=2 200 OK 52ms dhtmlxcommon.js (regel 203)
GET http://tiger/lt2/connector_grades.php?marker_id=3 200 OK 52ms dhtmlxcommon.js (regel 203)
GET http://tiger/lt2/connector_grades.php?marker_id=4 200 OK 52ms dhtmlxcommon.js (regel 203)
GET http://tiger/lt2/connector_grades.php?marker_id=5 200 OK 52ms dhtmlxcommon.js (regel 203)
GET http://tiger/lt2/connector_grades.php?marker_id=6 200 OK 52ms dhtmlxcommon.js (regel 203)
GET http://tiger/lt2/connector_grades.php?marker_id=7 200 OK 53ms dhtmlxcommon.js (regel 203)
GET http://tiger/lt2/connector_grades.php?marker_id=6 200 OK 54ms dhtmlxcommon.js (regel 203)
GET http://tiger/lt2/connector_grades.php?marker_id=5 200 OK 53ms dhtmlxcommon.js (regel 203)
GET http://tiger/lt2/connector_grades.php?marker_id=4 200 OK 55ms dhtmlxcommon.js (regel 203)
GET http://tiger/lt2/connector_grades.php?marker_id=3 200 OK 53ms dhtmlxcommon.js (regel 203)
GET http://tiger/lt2/connector_grades.php?marker_id=2 200 OK 53ms dhtmlxcommon.js (regel 203)
GET http://tiger/lt2/connector_grades.php?marker_id=5 200 OK 52ms dhtmlxcommon.js (regel 203)
POST http://tiger/lt2/connector_grades.php?marker_id=4&editing=true 200 OK 105ms dhtmlxcommon.js (regel 203)
POST http://tiger/lt2/connector_grades.php?marker_id=4&editing=true 200 OK 113ms dhtmlxcommon.js (regel 203)
POST http://tiger/lt2/connector_grades.php?marker_id=4&editing=true 200 OK 260ms dhtmlxcommon.js (regel 203)
POST http://tiger/lt2/connector_grades.php?marker_id=3&editing=true 200 OK 310ms dhtmlxcommon.js (regel 203)
POST http://tiger/lt2/connector_grades.php?marker_id=2&editing=true 200 OK 363ms dhtmlxcommon.js (regel 203)
POST http://tiger/lt2/connector_grades.php?marker_id=3&editing=true 200 OK 138ms dhtmlxcommon.js (regel 203)
POST http://tiger/lt2/connector_grades.php?marker_id=4&editing=true 200 OK 183ms dhtmlxcommon.js (regel 203)
POST http://tiger/lt2/connector_grades.php?marker_id=5&editing=true 200 OK 405ms dhtmlxcommon.js (regel 203)
POST http://tiger/lt2/connector_grades.php?marker_id=6&editing=true 200 OK 451ms dhtmlxcommon.js (regel 203)
POST http://tiger/lt2/connector_grades.php?marker_id=7&editing=true 200 OK 495ms dhtmlxcommon.js (regel 203)
POST http://tiger/lt2/connector_grades.php?marker_id=6&editing=true 200 OK 538ms 
dhtmlxcommon.js (regel 203)
POST http://tiger/lt2/connector_grades.php?marker_id=5&editing=true 200 OK 581ms dhtmlxcommon.js (regel 203)
POST http://tiger/lt2/connector_grades.php?marker_id=4&editing=true 200 OK 624ms dhtmlxcommon.js (regel 203)
POST http://tiger/lt2/connector_grades.php?marker_id=3&editing=true 200 OK 678ms dhtmlxcommon.js (regel 203)
POST http://tiger/lt2/connector_grades.php?marker_id=2&editing=true 200 OK 721ms dhtmlxcommon.js (regel 203)
POST http://tiger/lt2/connector_grades.php?marker_id=5&editing=true 200 OK 764ms dhtmlxcommon.js (regel 203)

You use dataprocessor in “auto send” mode. It means the request is sent to the server right after a row is added, deleted or edited.

If you need to send request after certain modifications in grid, you need to disable automatic update and send data when sendData called:

docs.dhtmlx.com/doku.php?id=dhtm … ialization

Alexandra,

Thanks for your response, but can you help me on my way to show me where to put these changes in my source code?

dpGrades = new dataProcessor(“connector_grades.php?marker_id=”+g_marker_id);
dpGrades.setUpdateMode(“off”);

and to send data to the server you need to call dpGrades.sendData();

When and where should I call dpGrades.sendData() and the others (dpAccommodation, dpContact)?

sendData() should be called when you want to send changes to the server. You complained that a request was sent after adding a single row - it was automatic update. I provided solution for custom sending data. And you need to decide when sendData needs being called. Possibly it could be “Send” button with onclick handler.