ParamQuery grid support forum
General Category => Help for ParamQuery Grid (free version) => Topic started by: Eagle_f90 on February 06, 2016, 03:11:59 am
-
I am able to successfully display data in my grid when I don't run into any problems getting the data but now I want to display an error message to the user if I run into any problems getting the data. I found http://paramquery.com/api#option-dataModel-error but am not sure how to combine it with a successful call. Also, my understanding of the 3 parameters in that function are that they will only return the core Error data and not a custom message that I return. I can display the Error status code if I have to but it would be nice to display a more user friendly message if possible. Thank you
var dataModel =
{
location: "remote",
dataType: "json",
method: "POST",
contentType: "application/json; charset=UTF-8",
url: '@Url.RouteUrl("GetChangeOrders")',
getData: function (dataJson)
{
return { data: dataJson };
}
};
var obj =
{
collapsible: false,
colModel: colModel,
dataModel: dataModel,
editable: false,
filterModel: { on: true, mode: "AND", header: true },
flexHeight: true,
numberCell: { show: false },
roundCorners: true,
scrollModel: [lastColumn = "None"],
sortDir: ["up"],
sortIndx: ["ID"],
sorting: "local",
stripeRows: true,
title: "IT Change Orders",
width: $(window).width() - 10,
wrap: false
};
-
Displaying a custom error message is simple:
dataModel:{
error: function( ){
alert( 'custom message' );
}
,..
}
-
But that would do a pop-up error correct? I don't want a popup for an error displayed like the "no rows" message.
-
That one is:
error: function( ){
var oldMsg = $grid.pqGrid( "option", "strNoRows" );
$grid.pqGrid( "option", "strNoRows", "custom message");
$grid.pqGrid( "refresh" );
//restore the normal message.
$grid.pqGrid( "option", "strNoRows", oldMsg);
},
-
Thanks for the help