Hi,
I can't able to delete first row in a grid. I can delete remaining all. After delete when i click save on that time only data will delete in database. I am using the following code for delete,
remove : function(vslname) {
var $grid = $("#off_hire_tab");
var data = $grid.pqGrid('option', 'dataModel.data');
var status = 0;
if(data[data.length - 1].fixture_id== 000 && data[data.length - 1].acct_period== 000 && data[data.length - 1].from_Date== 000 && data[data.length - 1].to_Date== 000 && data[data.length - 1].offhire_id== 000)
{
}
if(data.length != 0)
{
if(data[data.length - 1].fixture_id== 000 && data[data.length - 1].acct_period== 000 && data[data.length - 1].from_Date== 000 && data[data.length - 1].to_Date== 000 && data[data.length - 1].offhire_id== 000)
{
deleteList = "";
isAdded = null;
}
else
{
data[0].deleteList += data[data.length - 1].fixture_id+"," +data[data.length - 1].acct_period+"," + data[data.length - 1].from_Date+"," + data[data.length - 1].to_Date+"," + data[data.length - 1].offhire_id+",";
data[0].isDeleted = "Y";
//alert("this is the delette list "+data[0].deleteList);
}
$grid.pqGrid( "deleteRow", { rowIndx: data.length - 1 } );
}
else
{
$('div.jGrowl').find('div.jGrowl-notification').parent().remove();
$.jGrowl("OffHire cannot be deleted", { sticky: false });
exit;
}
After remove the record i am going to save. the following code is for save,
if(deleteList.length != 0)
{
var dList = data[0].deleteList.slice(9);
data[0].deleteList = dList;
dList = dList.substring(0, dList.length - 1);
$.ajax({
type : 'GET',
url : "deleteOffhire",
data : "dList="+dList,
contentType : "application/json; charset=utf-8",
success : function(response) {
if (response == true) {
$('div.jGrowl').find('div.jGrowl-notification').parent().remove();
$.jGrowl("Data was successfully Deleted", {
sticky : false
});
$("#off_hire_tab").pqGrid("refreshDataAndView");
}
},
error : function(e) {
},
});
$("#off_hire_tab").pqGrid("refreshDataAndView");
}
},
};
Please help me, here how can i delete one or more records. I cant able to delete the first record.