日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

Extjs 4.2 +Struts2 实现数据动态加载

發布時間:2024/1/17 编程问答 27 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Extjs 4.2 +Struts2 实现数据动态加载 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

//自定義一個的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 : "商品編號",

dataIndex : "commodityId",

sortable : true

}, {

text : "商品名稱",

dataIndex : "commodityName",

sortable : true

}, {

text : "商品價格",

dataIndex : "price",

sortable : true,

autoWidth : 50

}, {

text : "商品折扣",

dataIndex : "agio",

sortable : true

} ],

forceFit : true,

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

store : store,

displayInfo : true,

displayMsg : "顯示 {0} - {1} 條,共計 {2} 條",

emptyMsg : "沒有任何記錄",

width : "100%"


}) ]


});

var commodityQueryWindow = Ext.create("Ext.window.Window", {

width : 600,

height : 400,

title : "商品信息查詢",

resizable : false,

modal : true,

items : gridPanel

});

commodityQueryWindow.show();


}

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

Struts.xml 中的配置

? ? ? ?//method 可以寫成DMI方式

<action name="commodityQuery" class="com.rjxy.action.CommodityQueryAction" ? ? ? ? ?method="getCommodity" >

<result type="json">

? ? ? ? ? ? ? ? <param name="root">responseJson</param> ?

? ? ? ? ? ? </result>

</action>

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

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連接,網友可以用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;

}


轉載于:https://blog.51cto.com/kefly/1584415

總結

以上是生活随笔為你收集整理的Extjs 4.2 +Struts2 实现数据动态加载的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。