ExtJS 4.2 +struts2 for Dynamic Data loading

Source: Internet
Author: User

Customize one of the JS

function Commodityquery () {

Ext.state.Manager.setProvider (ext.create (' Ext.state.CookieProvider '));

Set up a model to use in our Store

Ext.define (' commodity ', {

Extend: ' Ext.data.Model ',

Fields: [

{name: ' Commodityid ', type: ' int '},

{name: ' Commodityname ', type: ' String '},

{name: ' Price ', type: ' Float '},

{name: ' Agio ', type: ' Float '}

]

});

var store = ext.create (' Ext.data.Store ', {

Model: ' Commodity ',

Proxy: {

Type: ' Ajax ',

URL: ' Commodityquery ',

Successproperty: ' Success ',

Reader: {

Type: ' JSON ',

Root: ' Results '

}

},

AutoLoad: {Start:0,limit:4}

});

var gridpanel = ext.create (' Ext.grid.Panel ', {

width:586,

height:375,

Store:store,

Columns: [{

Text: "Product number",

Dataindex: "Commodityid",

Sortable:true

}, {

Text: "Product name",

Dataindex: "Commodityname",

Sortable:true

}, {

Text: "Commodity price",

Dataindex: "Price",

Sortable:true,

Autowidth:50

}, {

Text: "Merchandise Discount",

Dataindex: "Agio",

Sortable:true

} ],

Forcefit:true,

Bbar: [Ext.create ("Ext.toolbar.Paging", {

Store:store,

Displayinfo:true,

Displaymsg: "Show {0}-{1} bar, total {2}",

Emptymsg: "No Records",

Width: "100%"


}) ]


});

var Commodityquerywindow = ext.create ("Ext.window.Window", {

width:600,

height:400,

Title: "Product Information Inquiry",

Resizable:false,

Modal:true,

Items:gridpanel

});

Commodityquerywindow.show ();


}

**********************

Configuration in the Struts.xml

Method can be written in DMI mode

<action name= "Commodityquery" class= "com.rjxy.action.CommodityQueryAction" method= "getcommodity" >

<result type= "JSON" >

<param name= "Root" >responseJson</param>

</result>

</action>

**********************

The variables and methods in Commodityqueryaction

Private String msg;

Private list<commodity> List;

Private Integer TotalCount;

Private Map Responsejson;

Private Saledaoimpl DAO;

Private Integer start;

Private Integer limit;

/**

* Query commodity list.

*/

Public String getcommodity () {

map<string, object> map = new hashmap<string, object> ();

try{

conn = Getconnection.getconn ();//jdbc connection, users can use Hibernate

DAO = new Saledaoimpl ();

List = Dao.queryallorder ();

if (list! = null) {

This.settotalcount (List.size ());

Map.put ("Results", list);

Map.put ("TotalCount", totalcount);

This.setresponsejson (map);

}

return SUCCESS;

}catch (Exception e) {

E.printstacktrace ();

return ERROR;

}


This article is from the "Learning" blog, so be sure to keep this source http://kefly.blog.51cto.com/1109349/1584415

ExtJS 4.2 +struts2 for Dynamic Data loading

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.