You can think of couple of ways to do this:
1) Keep a hidden boolean column which tells you whether the row has associated records.
rowData["related"] == true / false
Either don't display delete button in the row having related records or show a message when Delete button is clicked.
column.render = function(ui){
if(ui.rowData["related"]){
return "";
}
else{
return "<button>Delete</button>";
}
}
2) Check Server side after deleteList is posted. In this case you don't need jQuery.parseJSON because dataType is already "json"
obj received by success callback is constructed in PHP.
Format of obj is {related => boolean, msg => string, rows=> Array of rows }
if (deleteList.length) {
$.ajax($.extend({}, ajaxObj, {
data: { "deleteList": deleteList },
dataType:"json",
success: function (obj) {
//var obj = jQuery.parseJSON(rows);//not required.
if(obj.related){
//show message
alert(obj.msg);
$grid.pqGrid("rollback", { type: 'delete' });
}
else{
$grid.pqGrid("commit", { type: 'delete', rows: obj.rows });
}
},
complete: function (response) {
$grid.pqGrid("hideLoading");
$grid.pqGrid("rollback", { type: 'delete' });
}
}));
}