|
Title: [SOLVED] datagrid: show data load error Post by: gordis gmbh on April 25, 2016, 01:37:10 AM My remote server always returns a json object which is displayed as expected in edatagrid / datagrid. For e.g:
{"total":[1], "rows":[{ "id":1, "type":"Dummy Rack", "size":"40x50x60"}]} In case of an error while handling request, the server may also send a json containing error text, for instance: {"success":false,"message":"Received invalid Id:-1!"} On client side however, this results in a background Javascript error: TypeError: rows is undefined How should the json be formed so that in case of an error the "onLoadError" event of datagrid gets fired and the user be informed of error in an alert box? Title: Re: datagrid: show data load error Post by: gordis gmbh on April 26, 2016, 04:09:11 AM Further experiments with this issue brings me to the conclusion that datagrid cannot handle incompatible json data!
Here is a demo, that results in a javascript error (in console) when you click on the button "get more data from server": http://jsfiddle.net/8g89fntz/3/ (http://jsfiddle.net/8g89fntz/3/) If the received json is not as expected, this should be handled and informed ... I see no way to handle this because there isn't anything between onBeforeLoad and onLoadSuccess. And onLoadError doesn't get fired in this case! Thanks in advance for having a look. Title: Re: datagrid: show data load error Post by: Max Lamda on April 26, 2016, 04:33:15 AM onLoadError
fires, when you just return an empty page. Title: Re: datagrid: show data load error Post by: gordis gmbh on April 26, 2016, 04:42:59 AM @Max Lamda: yes, onLoadError does get fired in some cases... but not in this case (I have corrected this in my previous reply).
Title: Re: datagrid: show data load error Post by: Max Lamda on April 26, 2016, 07:02:15 AM Look here
http://www.jeasyui.com/forum/index.php?topic=1410.0 Title: Re: datagrid: show data load error Post by: jarry on April 26, 2016, 03:53:40 PM The 'loader' function can be overridden to display the customized error message.
Code: $('#dg').datagrid({Please look at this update example http://jsfiddle.net/8g89fntz/5/ Title: Re: datagrid: show data load error Post by: gordis gmbh on April 27, 2016, 09:53:45 AM Thanks for the support, that helped solve the problem!
|