GWT-EXT gridpanel displays formpanel fuzzy query results

Source: Internet
Author: User

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/

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.