jQuery EasyUI 擴(kuò)展 – DWR 加載器

2018-09-22 07:13 更新

jQuery EasyUI 擴(kuò)展 - DWR 加載器(DWR Loader)


jQuery EasyUI 擴(kuò)展 jQuery EasyUI 擴(kuò)展

包含 'dwrloader.js' 文件

使用 DWR 來(lái)獲取數(shù)據(jù),首先要包含 'dwrloader.js' 文件。

<script type="text/javascript" src="http://code.jquery.com/jquery-1.7.2.min.js" rel="external nofollow" ></script>
<script type="text/javascript" src="http://m.o2fo.com/try/jeasyui/jquery.easyui.min.js"></script>
<script type="text/javascript" src="dwrloader.js"></script>

把 DWR 方法分配給 'url' 屬性

作為默認(rèn)的 json 加載器,'url' 屬性表示要獲取 json 數(shù)據(jù)的遠(yuǎn)程 URL。
當(dāng)使用 DWR 加載器時(shí),我們應(yīng)分配一個(gè)函數(shù)給 'url' 屬性來(lái)從 DWR 獲取數(shù)據(jù)。
下面實(shí)例演示如何通過(guò)使用 DWR 加載器來(lái)顯示數(shù)據(jù)網(wǎng)格(datagrid):

	<table id="dg"></table>
	$(function(){
		$('#dg').datagrid({
			columns: [[
				{field:"id",title:'ID',width:80},
				{field:"text",title:'Text',width:100}
			]],
			singleSelect: true,
			autoRowHeight: false,
			width: 200,
			height: 200,
			url: MyTest.getDataGridData
		});
	});

Java 測(cè)試代碼

public class Test {
	public List<Map<String,Object>> getDataGridData(){
		List<Map<String,Object>> items = new ArrayList<Map<String,Object>>();
		Map<String,Object> item = new HashMap<String,Object>();
		item.put("id", 1);
		item.put("text", "text1");
		items.add(item);
		item = new HashMap<String,Object>();
		item.put("id", 2);
		item.put("text", "text2");
		items.add(item);
		return items;
	}
}

下載 jQuery EasyUI 實(shí)例

jquery-easyui-dwrloader.zip


jQuery EasyUI 擴(kuò)展 jQuery EasyUI 擴(kuò)展
以上內(nèi)容是否對(duì)您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號(hào)
微信公眾號(hào)

編程獅公眾號(hào)