jQuery EasyUI Extension -DWR Loader
jQuery EasyUI Extension
Include the 'dwrloader.js' file
To use DWR to fetch data, you must first include the 'dwrloader.js' file.
<script type="text/javascript" src="http://code.jquery.com/jquery-1.7.2.min.js"></script> <script type="text/javascript" src="http://www.w3cschool.cc/try/jeasyui/jquery.easyui.min.js"></script> <script type="text/javascript" src="dwrloader.js.html"></script>
Assign the DWR method to the 'url' attribute
As the default JSON loader, the 'url' attribute represents the remote URL from which to fetch JSON data.
When using the DWR loader, we should assign a function to the 'url' attribute to fetch data from DWR.
The following example demonstrates how to display a data grid (datagrid) using the DWR loader:
<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 Test Code
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;
}
}
Download jQuery EasyUI Examples
jquery-easyui-dwrloader.zip
jQuery EasyUI Extension Other Extensions