Please help me understand where I am going wrong with the context of objects in ParamQuery. I am trying to call an external php from a button in the toolbar.
My toolbar is created like this...
toolbar: {
cls: 'pq-toolbar-export',
items: [
{
type: 'button',
label: "Create StockDiff",
icon: 'ui-icon-document',
listeners: [{
"click": function () {
var grid = $(this).closest('.pq-grid');
var $selArray = $("#grid_php").pqGrid( "selection", { type: 'cell', method: 'getSelection' } );
if ($selArray.length == 1) {
var rowData = $selArray[0].rowData;
createStockDiff(grid, rowData);
}
}
}]
}
And then my function is like this...
function createStockDiff(grid, rowData) {
var url, type;
var partnumber = rowData.partnumber;
var mrpqty = rowData.mrpqty;
var talliscan = rowData.total;
var adjustqty = talliscan-mrpqty;
type = 'document';
url = "createstockdiff.php?pq_createhtml=1";
$.ajax($.extend({}, ajaxObj, {
context: grid,
url: url,
data: { partnumber: partnumber, count: talliscan, mrpqty: mrpqty },
success: function (response) {
// this.refreshRow({ rowIndx: rowIndx});
},
error: function () {
// this.refreshRow({ rowIndx: rowIndx});
}
}))
}
The selArray, rowData and function call activate ok, but the ajaxObj here...
var ajaxObj = {
dataType: "JSON",
beforeSend: function () {
this.showLoading();
},
...reports "Object doesn't support property or method 'showLoading'.
I already use the ajax process in other parts of the code so I know it is ok, but I think I am not correctly passing the grid object to my function.
Would you be able to explain why I can't pass the grid object in this way and help me to better understand how ParamQuery works? It is obvious that I don't understand it at all.
I really hope you can help.
Many thanks. Tony.