easyui datagrid- loadData
http://code.reloado.com/oeasyrik1/104/edit#javascript,html
<html>
<head>
<link rel="stylesheet" type="text/css" href="http://www.jeasyui.com/easyui//themes/default/easyui.css">
<link rel="stylesheet" type="text/css" href="http://www.jeasyui.com/easyui/themes/icon.css">
<link rel="stylesheet" type="text/css" href="http://www.jeasyui.com/easyui/demo/demo.css">
<script type="text/javascript" src="http://www.jeasyui.com/easyui/jquery.min.js"></script>
<script type="text/javascript" src="http://www.jeasyui.com/easyui/jquery.easyui.min.js"></script>
<script type="text/javascript" src="http://www.jeasyui.com/easyui/datagrid-scrollview.js"></script>
<script type="text/javascript" src="http://www.jeasyui.com/easyui/datagrid-dnd.js"></script>
<script>
var data = {"total":12,"rows":[
{"id":160550,"itemid":"1","1productid":"11111","listprice":"kom","unitcost": "7.3","attr1":"122.18000000","status":"940.62","attr2":"25.00"},
{"id":160769,"itemid":"2","1productid":"22222","listprice":"kom","unitcost": "7.2","attr1":"122.18000000","status":"879.70","attr2":"25.00"},
{"id":160770,"itemid":"3","1productid":"33333","listprice":"kom","unitcost": "7.2","attr1":"122.18000000","status":"879.70","attr2":"25.00"}
]}
function loadMe(){
$('#dg').datagrid('loadData',data);
//$('#dg').datagrid('load', 'file.json');
}
function onLoadSuccess(data){
$('#dg').datagrid('enableDnd');
}
</script>
</head>
<body>
<br>
<a href="javascript:void(0)" class="easyui-linkbutton" onclick="loadMe()">Click to load</a> <br> <br> <br>
<div>
<table id="dg" class="easyui-datagrid" title="DataGrid" style="width:700px;height:250px" data-options="
singleSelect:false,
ctrlSelect:true,
idField:'id',
view:scrollview,pagination:true,pageSize:50,pageList:[50],
dragSelection: true,
onLoadSuccess: onLoadSuccess
">
<thead>
<tr>
<th data-options="field:'itemid',width:80">Item ID</th>
<th data-options="field:'1productid',width:90">Product</th>
<th data-options="field:'listprice',width:80,align:'right'">List Price</th>
<th data-options="field:'unitcost',width:80,align:'right'">Unit Cost</th>
<th data-options="field:'attr1',width:150">Attribute</th>
<th data-options="field:'status',width:60,align:'center'">Status</th>
<th data-options="field:'attr2',width:120,align:'center'">Attr2</th>
</tr>
</thead>
</table>
</div>
</body>
</html>
留言
張貼留言