First of all, you need to submit the query conditions. Here I use a servlet named search to process fuzzy queries. In formpanel's form
The onactioncomplete event is monitored to obtain the query results returned by the servlet. The onactioncomplete event must be returned by the servlet.
Return a JSON: {"success", true}. This event is triggered only when success is true. If it is false, it is triggered.
Onactionfailed event.
However, I still need to get the query result. If the query result needs to trigger onactioncomplete and carry the query result, my JSON format must be as follows:
{Success: True, Results: '{totalcount: 1, topics:
[{ID: 100, custname: "neeke", Summarization: "summary", linkman: "Contact", linkphone: "Contact
Phone ", createtime:" "}]} '}
However, the responsetext of onactioncomplete is of the string type. How can I obtain the results value?
After repeated exploration, I finally got it done. First use JSON. Decode () to convert responsetext to the javascriptobject type, and then
Use javascriptobjecthelper. getattribute (jsobj,
"Results") to retrieve the results value of the string type.
Grid. getstore (). loadjsondata (results, false) loads the query results to gridpanel. DetailsCodeAs follows:
View Source Code
Print
Help 01.
Searchpanel. getform (). addlistener (
New
Formlisteneradapter (){
02.
@ Override
03.
Public void onactioncomplete (Form, int httpstatus,
04.
String responsetext ){
05.
Required criptobject jsobj = JSON. Decode (responsetext );
06.
String Results = javascriptobjecthelper. getattribute (jsobj,
"Results"
);
07.
Grid. getstore (). loadjsondata (results,
False
);
08.
}
09.
});
The second Boolean parameter of the loadjsondata () method specifies whether to append data to the gridpanel. Here I set it to false, in this way, the data in the gridpanel is automatically cleared before the query result is loaded.
Original reprintedArticlePlease note, reproduced from: neeke [http://www.ineeke.cn
]
Link: http://www.ineeke.cn/archives/gridpanelloadjsondatafromsearchresult/