| Page 1 of 1 | [ 6 posts ] |
|
Hi I could really use some help.
When i am returning 0 results / empty array to my datasource - the datable shows a message of "Data error.", I feel this is rather unsightly but I cant for the life of me figure out a way to change this message to something more friendly. Is it possible to have it display something else ? edit : to be more specific: at the doBeforeParseData ( oRequest , oFullResponse , oCallback ) function when i return no results the oFullResponse param is null - which is what i assume causes the "Data error." to display. Ideally it would say "No results returned" Can anyone help? |
|
instead of null, it should be [], an empty array, not no array. It does expect an array, even if empty
|
|
Hi satyam thanks for your response, I have implemented your suggestion as shown below, however i still seem to be getting the "Data error." message?
Should i be parsing the empty array into JSON or something? Code: messages_data_source = new YAHOO.util.XHRDataSource("CIIM/ValidationResults?" , { responseType : YAHOO.util.DataSource.TYPE_JSON, doBeforeParseData : function( oRequest , oFullResponse , oCallback ) { if(!oFullResponse) { oFullResponse = []; } return oFullResponse; }, responseSchema : { resultsList : "validation_results", fields : [ {key : "id"}, {key : "conformance"}, {key : "status"}, {key : "messages"} ] } }); |
|
You still have to respect the structure of oFullResponse, you cannot just set oFullResponse to [] or null or whatever. oFullResponse has a place for the data, which you are configuring through the resultsList property. The oFullResponse you return should still have that.
The easiest way, instead of theorizing, is to put a breakpoint in doBeforeParseData and get a valid, non-empty reply (which I assume you are able to display normally) and check out where the data is, it should be an array of object literals. It is that array which you should replace with an empty array, leaving the rest just the same. |
|
Thankyou I will have a go at that now and see if I can put your suggestion into practise.
|
|
THANKYOU SO MUCH!! it now works!
solution for JSON below: Code: messages_data_source = new YAHOO.util.XHRDataSource("CIIM/ValidationResults?" , { responseType : YAHOO.util.DataSource.TYPE_JSON, doBeforeParseData : function( oRequest , oFullResponse , oCallback ) { if(!oFullResponse) { oFullResponse = {"results":[]}; } return oFullResponse; }, responseSchema : { resultsList : "results", fields : [ {key : "id"}, {key : "conformance"}, {key : "status"}, {key : "messages"} ] } }); |
| Page 1 of 1 | [ 6 posts ] |
| You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum |
© 2006-2013 Yahoo! Inc. All rights reserved.
All code on this site is licensed under the BSD License unless stated otherwise.
About This Site · Security Contact Info
Powered by phpBB® Forum Software © phpBB Group