Temporary solution for delete on error event on jqgrid

Posted: August 27, 2011 in web

************js****************

jQuery("#list10").jqGrid('navGrid','#pager10',
	{edit:1,add:1,del:<?php echo $obj->checkRoleAccess('wo','d',$_SESSION['user']['Role']); ?>,cloneToTop:true,addicon:"ui-icon-document"
	},
 	{closeAfterEdit: true,closeAfterAdd: true, width:400}, // edit options
	{closeAfterEdit: true,closeAfterAdd: true, width:400,addCaption:"Add"}, // add options
	{closeOnEscape:true,

	beforeSubmit:function(rowid){
			var ret = $.ajax({
							url: 'selectdata.php?q=checkdel&WorkOrderID='+rowid,
							async:false
					}).responseText
		if(ret == 0){
			alert('Please delete child Scope items');
		}
		return [true,''];
	}
	}, // del options
	{closeOnEscape:true,position:'right'} // search options

)

************selectdata.php****************

	case 'checkdel':
			  $sql = "SELECT * FROM trn_woscope WHERE WorkOrderID = " . $_REQUEST['WorkOrderID'];
			  $res = mysql_query($sql);
			  if(mysql_num_rows($res))
			  	echo '0';
			  else
			  	echo '1';
	break;
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s