Hello ,
1) I am trying to post the AJAX just after I use up and down arrow keys. But I got "evt.keyCode" "undefined" and therefore it does not run if clause.
2) Meanwhile lets say user edited two cells. Although user edited 2 cells I would like to set new value into additional 2 cells more according to the cells edited. Can I do this using the value return from AJAX assigning the "new json data" data of the line?
3) When user makes an invalid entry while editing a cell, I would like to post it with AJAX and I would like to Show the error message like "process:error" after checking the server error. Can I do this? The reason why I want this, because I remember a sample showing the error very nicely then change the shape of the cell and it prevent user to out of it. In my application there is a warehouse and if user orders more quantity of goods than what they have in stock, there must be an error message.
SAMPLE on setting value:
There is way of shipment information in 2nd cell. It is "Express,Normal", Price information is on 4th cell.
If user picks "Express" on 2nd cell just after it is recorded, if I assign a value as ben {"COL1:"="Express","COL4"="15 USD"} on "PQGrid.asp?isl=Save", can PqGrid set this?
editModel
,editModel: {
clicksToEdit: '1',
saveKey: $.ui.keyCode.ENTER,
select: false,
keyUpDown: true,
cellBorderWidth: 0
}
Save Code
/* *********************************************************************************************************** */
$grid.on( "pqgridcellsave", function( evt, ui ) {
var rowData = $grid.pqGrid( "getRowData", {rowIndx: ui.rowIndx} );
var oldVal= ui.oldVal;
var newVal= ui.newVal;
var keyCode=evt.keyCode;
alert(keyCode);
var json_arr = JSON.stringify({
action: 'update'
,grid_id: 'grid_search'
,rowIndx: ui.rowIndx
,rowIndxPage: ui.rowIndxPage
,colIndx: ui.colIndx
,dataIndx: ui.dataIndx
,oldVal: ui.oldVal
,newVal: ui.newVal
,rowData: rowData
,keyCode:evt.keyCode
});
//window.console && console.log(json_arr);
$('#Post_id').html(json_arr);
//if ((keyCode == 40 || keyCode == 38) && newVal != oldVal) {
$.ajax({
type: "POST",
url:'PQGrid.asp?isl=Save',
data:rowData,
cache:false,
statusCode: {404: function(){}},
beforeSend: function(jqXHR, settings){
alert('beforeSend\nstatus:'+jqXHR.status+'\n jqXHRstatusText:'+jqXHR.statusText);
$('#overlay').show();
},
success: function(data,textStatus,jqXHR){
alert('Success\nstatus:'+jqXHR.status+'\n jqXHRstatusText:'+jqXHR.statusText+'\n textStatus:'+textStatus);
$('#Post_id').html(data).show();
},
error: function(jqXHR, textStatus, errorThrown){
alert('Error\nstatus:'+jqXHR.status+'\n jqXHRstatusText:'+jqXHR.statusText+'\n textStatus:'+textStatus);
$('<div></div>').html('Hata Kodu:'+jqXHR.status+'<br>'+jqXHR.statusText).dialog({position: ['center','top'],modal:true,zindex:9002,title:textStatus});
},
complete:function(jqXHR, textStatus) {
alert('Complete\nstatus:'+jqXHR.status+'\n jqXHRstatusText:'+jqXHR.statusText+'\n textStatus:'+textStatus);
$('#overlay').hide();
}
});
//}
});
Html
<div style='float:left;width:40%;'>
<div id='Post_id'>Post Message</div>
<div id='Hata_id'>Error Message</div>
</div>