Commit ab2872c1 authored by 季圣华's avatar 季圣华
Browse files

升级easyUI到1.9.4版本

parent 0527b980
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Basic ComboTreeGrid - jQuery EasyUI Demo</title>
<link rel="stylesheet" type="text/css" href="../../themes/default/easyui.css">
<link rel="stylesheet" type="text/css" href="../../themes/icon.css">
<link rel="stylesheet" type="text/css" href="../demo.css">
<script type="text/javascript" src="../../jquery.min.js"></script>
<script type="text/javascript" src="../../jquery.easyui.min.js"></script>
</head>
<body>
<h2>Basic ComboTreeGrid</h2>
<p>Click the right arrow button to show the TreeGrid.</p>
<div style="margin:20px 0"></div>
<div class="easyui-panel" style="width:100%;max-width:400px;padding:30px 60px;">
<div style="margin-bottom:20px">
<input class="easyui-combotreegrid" data-options="
width:'100%',
panelWidth:500,
label:'Select Item:',
labelPosition:'top',
url:'treegrid_data1.json',
idField:'id',
treeField:'name',
columns:[[
{field:'name',title:'Name',width:200},
{field:'size',title:'Size',width:100},
{field:'date',title:'Date',width:100}
]]">
</div>
</div>
</body>
</html>
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Multiple ComboTreeGrid - jQuery EasyUI Demo</title>
<link rel="stylesheet" type="text/css" href="../../themes/default/easyui.css">
<link rel="stylesheet" type="text/css" href="../../themes/icon.css">
<link rel="stylesheet" type="text/css" href="../demo.css">
<script type="text/javascript" src="../../jquery.min.js"></script>
<script type="text/javascript" src="../../jquery.easyui.min.js"></script>
</head>
<body>
<h2>Multiple ComboTreeGrid</h2>
<p>Click the right arrow button to show the TreeGrid and select items.</p>
<div style="margin:20px 0"></div>
<div class="easyui-panel" style="width:100%;max-width:400px;padding:30px 60px;">
<div style="margin-bottom:20px">
<input class="easyui-combotreegrid" data-options="
width:'100%',
panelWidth:500,
label:'Select Items:',
labelPosition:'top',
url:'treegrid_data1.json',
idField:'id',
treeField:'name',
multiple:true,
value:['211','31'],
columns:[[
{field:'name',title:'Name',width:200},
{field:'size',title:'Size',width:100},
{field:'date',title:'Date',width:100}
]]">
</div>
</div>
</body>
</html>
\ No newline at end of file
...@@ -11,11 +11,8 @@ ...@@ -11,11 +11,8 @@
</head> </head>
<body> <body>
<h2>Aligning Columns in DataGrid</h2> <h2>Aligning Columns in DataGrid</h2>
<div class="demo-info"> <p>Use align and halign properties to set the alignment of the columns and their header.</p>
<div class="demo-tip icon-tip"></div> <div style="margin:20px 0;"></div>
<div>Use align and halign properties to set the alignment of the columns and their header.</div>
</div>
<div style="margin:10px 0;"></div>
<table class="easyui-datagrid" title="Aligning Columns in DataGrid" style="width:700px;height:250px" <table class="easyui-datagrid" title="Aligning Columns in DataGrid" style="width:700px;height:250px"
data-options="singleSelect:true,collapsible:true,url:'datagrid_data1.json',method:'get'"> data-options="singleSelect:true,collapsible:true,url:'datagrid_data1.json',method:'get'">
......
...@@ -11,11 +11,8 @@ ...@@ -11,11 +11,8 @@
</head> </head>
<body> <body>
<h2>Basic DataGrid</h2> <h2>Basic DataGrid</h2>
<div class="demo-info"> <p>The DataGrid is created from markup, no JavaScript code needed.</p>
<div class="demo-tip icon-tip"></div> <div style="margin:20px 0;"></div>
<div>The DataGrid is created from markup, no JavaScript code needed.</div>
</div>
<div style="margin:10px 0;"></div>
<table class="easyui-datagrid" title="Basic DataGrid" style="width:700px;height:250px" <table class="easyui-datagrid" title="Basic DataGrid" style="width:700px;height:250px"
data-options="singleSelect:true,collapsible:true,url:'datagrid_data1.json',method:'get'"> data-options="singleSelect:true,collapsible:true,url:'datagrid_data1.json',method:'get'">
......
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Cache Editor for DataGrid - jQuery EasyUI Demo</title>
<link rel="stylesheet" type="text/css" href="../../themes/default/easyui.css">
<link rel="stylesheet" type="text/css" href="../../themes/icon.css">
<link rel="stylesheet" type="text/css" href="../demo.css">
<script type="text/javascript" src="../../jquery.min.js"></script>
<script type="text/javascript" src="../../jquery.easyui.min.js"></script>
</head>
<body>
<h2>Cache Editor for DataGrid</h2>
<p>This example shows how to cache the editors for datagrid to improve the editing speed.</p>
<div style="margin:20px 0;"></div>
<table id="dg" class="easyui-datagrid" title="Cache Editor for DataGrid" style="width:700px;height:auto"
data-options="
iconCls: 'icon-edit',
singleSelect: true,
toolbar: '#tb',
url: 'datagrid_data1.json',
method: 'get',
onClickRow: onClickRow
">
<thead>
<tr>
<th data-options="field:'itemid',width:80">Item ID</th>
<th data-options="field:'productid',width:100,
formatter:function(value,row){
return row.productname;
},
editor:{
type:'combobox',
options:{
valueField:'productid',
textField:'productname',
method:'get',
url:'products.json',
required:true
}
}">Product</th>
<th data-options="field:'listprice',width:80,align:'right',editor:{type:'numberbox',options:{precision:2}}">List Price</th>
<th data-options="field:'unitcost',width:80,align:'right',editor:{type:'numberbox',options:{precision:2}}">Unit Cost</th>
<th data-options="field:'attr1',width:250,editor:'text'">Attribute</th>
<th data-options="field:'status',width:60,align:'center',editor:{type:'checkbox',options:{on:'P',off:''}}">Status</th>
</tr>
</thead>
</table>
<div id="tb" style="height:auto">
<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-save',plain:true" onclick="accept()">Accept</a>
<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-undo',plain:true" onclick="reject()">Reject</a>
<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-search',plain:true" onclick="getChanges()">GetChanges</a>
</div>
<script type="text/javascript">
(function($){
function getCacheContainer(t){
var view = $(t).closest('div.datagrid-view');
var c = view.children('div.datagrid-editor-cache');
if (!c.length){
c = $('<div class="datagrid-editor-cache" style="position:absolute;display:none"></div>').appendTo(view);
}
return c;
}
function getCacheEditor(t, field){
var c = getCacheContainer(t);
return c.children('div.datagrid-editor-cache-' + field);
}
function setCacheEditor(t, field, editor){
var c = getCacheContainer(t);
c.children('div.datagrid-editor-cache-' + field).remove();
var e = $('<div class="datagrid-editor-cache-' + field + '"></div>').appendTo(c);
e.append(editor);
}
var editors = $.fn.datagrid.defaults.editors;
for(var editor in editors){
var opts = editors[editor];
(function(){
var init = opts.init;
opts.init = function(container, options){
var field = $(container).closest('td[field]').attr('field');
var ed = getCacheEditor(container, field);
if (ed.length){
ed.appendTo(container);
return ed.find('.datagrid-editable-input');
} else {
return init(container, options);
}
}
})();
(function(){
var destroy = opts.destroy;
opts.destroy = function(target){
if ($(target).hasClass('datagrid-editable-input')){
var field = $(target).closest('td[field]').attr('field');
setCacheEditor(target, field, $(target).parent().children());
} else if (destroy){
destroy(target);
}
}
})();
}
})(jQuery);
</script>
<script type="text/javascript">
var editIndex = undefined;
function endEditing(){
if (editIndex == undefined){return true}
if ($('#dg').datagrid('validateRow', editIndex)){
var ed = $('#dg').datagrid('getEditor', {index:editIndex,field:'productid'});
var productname = $(ed.target).combobox('getText');
$('#dg').datagrid('getRows')[editIndex]['productname'] = productname;
$('#dg').datagrid('endEdit', editIndex);
editIndex = undefined;
return true;
} else {
return false;
}
}
function onClickRow(index){
if (editIndex != index){
if (endEditing()){
$('#dg').datagrid('selectRow', index)
.datagrid('beginEdit', index);
editIndex = index;
} else {
$('#dg').datagrid('selectRow', editIndex);
}
}
}
function accept(){
if (endEditing()){
$('#dg').datagrid('acceptChanges');
}
}
function reject(){
$('#dg').datagrid('rejectChanges');
editIndex = undefined;
}
function getChanges(){
var rows = $('#dg').datagrid('getChanges');
alert(rows.length+' rows are changed!');
}
</script>
</body>
</html>
\ No newline at end of file
...@@ -11,26 +11,22 @@ ...@@ -11,26 +11,22 @@
</head> </head>
<body> <body>
<h2>Cell Editing in DataGrid</h2> <h2>Cell Editing in DataGrid</h2>
<div class="demo-info"> <p>Click a cell to start editing.</p>
<div class="demo-tip icon-tip"></div> <div style="margin:20px 0;"></div>
<div>Click a cell to start editing.</div>
</div>
<div style="margin:10px 0;"></div>
<table id="dg" class="easyui-datagrid" title="Cell Editing in DataGrid" style="width:700px;height:auto" <table id="dg" title="Cell Editing in DataGrid" style="width:700px;height:auto"
data-options=" data-options="
iconCls: 'icon-edit', iconCls: 'icon-edit',
singleSelect: true, singleSelect: true,
url: 'datagrid_data1.json', url: 'datagrid_data1.json',
method:'get', method:'get'
onClickCell: onClickCell
"> ">
<thead> <thead>
<tr> <tr>
<th data-options="field:'itemid',width:80">Item ID</th> <th data-options="field:'itemid',width:80">Item ID</th>
<th data-options="field:'productid',width:100,editor:'text'">Product</th> <th data-options="field:'productid',width:100,editor:'text'">Product</th>
<th data-options="field:'listprice',width:80,align:'right',editor:{type:'numberbox',options:{precision:1}}">List Price</th> <th data-options="field:'listprice',width:80,align:'right',editor:{type:'numberbox',options:{precision:2}}">List Price</th>
<th data-options="field:'unitcost',width:80,align:'right',editor:'numberbox'">Unit Cost</th> <th data-options="field:'unitcost',width:80,align:'right',editor:{type:'numberbox',options:{precision:2}}">Unit Cost</th>
<th data-options="field:'attr1',width:250,editor:'text'">Attribute</th> <th data-options="field:'attr1',width:250,editor:'text'">Attribute</th>
<th data-options="field:'status',width:60,align:'center',editor:{type:'checkbox',options:{on:'P',off:''}}">Status</th> <th data-options="field:'status',width:60,align:'center',editor:{type:'checkbox',options:{on:'P',off:''}}">Status</th>
</tr> </tr>
...@@ -51,32 +47,48 @@ ...@@ -51,32 +47,48 @@
} }
} }
$(this).datagrid('beginEdit', param.index); $(this).datagrid('beginEdit', param.index);
var ed = $(this).datagrid('getEditor', param);
if (ed){
if ($(ed.target).hasClass('textbox-f')){
$(ed.target).textbox('textbox').focus();
} else {
$(ed.target).focus();
}
}
for(var i=0; i<fields.length; i++){ for(var i=0; i<fields.length; i++){
var col = $(this).datagrid('getColumnOption', fields[i]); var col = $(this).datagrid('getColumnOption', fields[i]);
col.editor = col.editor1; col.editor = col.editor1;
} }
}); });
} },
enableCellEditing: function(jq){
return jq.each(function(){
var dg = $(this);
var opts = dg.datagrid('options');
opts.oldOnClickCell = opts.onClickCell;
opts.onClickCell = function(index, field){
if (opts.editIndex != undefined){
if (dg.datagrid('validateRow', opts.editIndex)){
dg.datagrid('endEdit', opts.editIndex);
opts.editIndex = undefined;
} else {
return;
}
}
dg.datagrid('selectRow', index).datagrid('editCell', {
index: index,
field: field
});
opts.editIndex = index;
opts.oldOnClickCell.call(this, index, field);
}
});
}
}); });
var editIndex = undefined; $(function(){
function endEditing(){ $('#dg').datagrid().datagrid('enableCellEditing');
if (editIndex == undefined){return true} })
if ($('#dg').datagrid('validateRow', editIndex)){
$('#dg').datagrid('endEdit', editIndex);
editIndex = undefined;
return true;
} else {
return false;
}
}
function onClickCell(index, field){
if (endEditing()){
$('#dg').datagrid('selectRow', index)
.datagrid('editCell', {index:index,field:field});
editIndex = index;
}
}
</script> </script>
</body> </body>
</html> </html>
\ No newline at end of file
...@@ -11,11 +11,8 @@ ...@@ -11,11 +11,8 @@
</head> </head>
<body> <body>
<h2>DataGrid Cell Style</h2> <h2>DataGrid Cell Style</h2>
<div class="demo-info"> <p>The cells which listprice value is less than 30 are highlighted.</p>
<div class="demo-tip icon-tip"></div> <div style="margin:20px 0;"></div>
<div>The cells which listprice value is less than 30 are highlighted.</div>
</div>
<div style="margin:10px 0;"></div>
<table class="easyui-datagrid" title="DataGrid Cell Style" style="width:700px;height:250px" <table class="easyui-datagrid" title="DataGrid Cell Style" style="width:700px;height:250px"
data-options=" data-options="
singleSelect: true, singleSelect: true,
......
...@@ -11,11 +11,8 @@ ...@@ -11,11 +11,8 @@
</head> </head>
<body> <body>
<h2>CheckBox Selection on DataGrid</h2> <h2>CheckBox Selection on DataGrid</h2>
<div class="demo-info"> <p>Click the checkbox on header to select or unselect all selections.</p>
<div class="demo-tip icon-tip"></div> <div style="margin:20px 0;"></div>
<div>Click the checkbox on header to select or unselect all selections.</div>
</div>
<div style="margin:10px 0;"></div>
<table id="dg" class="easyui-datagrid" title="CheckBox Selection on DataGrid" style="width:700px;height:250px" <table id="dg" class="easyui-datagrid" title="CheckBox Selection on DataGrid" style="width:700px;height:250px"
data-options="rownumbers:true,singleSelect:true,url:'datagrid_data1.json',method:'get'"> data-options="rownumbers:true,singleSelect:true,url:'datagrid_data1.json',method:'get'">
......
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Client Side Pagination in DataGrid - jQuery EasyUI Demo</title>
<link rel="stylesheet" type="text/css" href="../../themes/default/easyui.css">
<link rel="stylesheet" type="text/css" href="../../themes/icon.css">
<link rel="stylesheet" type="text/css" href="../demo.css">
<script type="text/javascript" src="../../jquery.min.js"></script>
<script type="text/javascript" src="../../jquery.easyui.min.js"></script>
</head>
<body>
<h2>Client Side Pagination in DataGrid</h2>
<p>This sample shows how to implement client side pagination in DataGrid.</p>
<div style="margin:20px 0;"></div>
<table id="dg" title="Client Side Pagination" style="width:700px;height:300px" data-options="
rownumbers:true,
singleSelect:true,
autoRowHeight:false,
pagination:true,
pageSize:10">
<thead>
<tr>
<th field="inv" width="80">Inv No</th>
<th field="date" width="100">Date</th>
<th field="name" width="80">Name</th>
<th field="amount" width="80" align="right">Amount</th>
<th field="price" width="80" align="right">Price</th>
<th field="cost" width="100" align="right">Cost</th>
<th field="note" width="110">Note</th>
</tr>
</thead>
</table>
<script>
(function($){
function pagerFilter(data){
if ($.isArray(data)){ // is array
data = {
total: data.length,
rows: data
}
}
var target = this;
var dg = $(target);
var state = dg.data('datagrid');
var opts = dg.datagrid('options');
if (!state.allRows){
state.allRows = (data.rows);
}
if (!opts.remoteSort && opts.sortName){
var names = opts.sortName.split(',');
var orders = opts.sortOrder.split(',');
state.allRows.sort(function(r1,r2){
var r = 0;
for(var i=0; i<names.length; i++){
var sn = names[i];
var so = orders[i];
var col = $(target).datagrid('getColumnOption', sn);
var sortFunc = col.sorter || function(a,b){
return a==b ? 0 : (a>b?1:-1);
};
r = sortFunc(r1[sn], r2[sn]) * (so=='asc'?1:-1);
if (r != 0){
return r;
}
}
return r;
});
}
var start = (opts.pageNumber-1)*parseInt(opts.pageSize);
var end = start + parseInt(opts.pageSize);
data.rows = state.allRows.slice(start, end);
return data;
}
var loadDataMethod = $.fn.datagrid.methods.loadData;
var deleteRowMethod = $.fn.datagrid.methods.deleteRow;
$.extend($.fn.datagrid.methods, {
clientPaging: function(jq){
return jq.each(function(){
var dg = $(this);
var state = dg.data('datagrid');
var opts = state.options;
opts.loadFilter = pagerFilter;
var onBeforeLoad = opts.onBeforeLoad;
opts.onBeforeLoad = function(param){
state.allRows = null;
return onBeforeLoad.call(this, param);
}
var pager = dg.datagrid('getPager');
pager.pagination({
onSelectPage:function(pageNum, pageSize){
opts.pageNumber = pageNum;
opts.pageSize = pageSize;
pager.pagination('refresh',{
pageNumber:pageNum,
pageSize:pageSize
});
dg.datagrid('loadData',state.allRows);
}
});
$(this).datagrid('loadData', state.data);
if (opts.url){
$(this).datagrid('reload');
}
});
},
loadData: function(jq, data){
jq.each(function(){
$(this).data('datagrid').allRows = null;
});
return loadDataMethod.call($.fn.datagrid.methods, jq, data);
},
deleteRow: function(jq, index){
return jq.each(function(){
var row = $(this).datagrid('getRows')[index];
deleteRowMethod.call($.fn.datagrid.methods, $(this), index);
var state = $(this).data('datagrid');
if (state.options.loadFilter == pagerFilter){
for(var i=0; i<state.allRows.length; i++){
if (state.allRows[i] == row){
state.allRows.splice(i,1);
break;
}
}
$(this).datagrid('loadData', state.allRows);
}
});
},
getAllRows: function(jq){
return jq.data('datagrid').allRows;
}
})
})(jQuery);
function getData(){
var rows = [];
for(var i=1; i<=800; i++){
var amount = Math.floor(Math.random()*1000);
var price = Math.floor(Math.random()*1000);
rows.push({
inv: 'Inv No '+i,
date: $.fn.datebox.defaults.formatter(new Date()),
name: 'Name '+i,
amount: amount,
price: price,
cost: amount*price,
note: 'Note '+i
});
}
return rows;
}
$(function(){
$('#dg').datagrid({data:getData()}).datagrid('clientPaging');
});
</script>
</body>
</html>
\ No newline at end of file
...@@ -11,11 +11,8 @@ ...@@ -11,11 +11,8 @@
</head> </head>
<body> <body>
<h2>Column Group</h2> <h2>Column Group</h2>
<div class="demo-info"> <p>The header cells can be merged. Useful to group columns under a category.</p>
<div class="demo-tip icon-tip"></div> <div style="margin:20px 0;"></div>
<div>The header cells can be merged. Useful to group columns under a category.</div>
</div>
<div style="margin:10px 0;"></div>
<table class="easyui-datagrid" title="Column Group" style="width:700px;height:250px" <table class="easyui-datagrid" title="Column Group" style="width:700px;height:250px"
data-options="rownumbers:true,singleSelect:true,url:'datagrid_data1.json',method:'get'"> data-options="rownumbers:true,singleSelect:true,url:'datagrid_data1.json',method:'get'">
<thead> <thead>
......
...@@ -11,13 +11,10 @@ ...@@ -11,13 +11,10 @@
</head> </head>
<body> <body>
<h2>DataGrid Complex Toolbar</h2> <h2>DataGrid Complex Toolbar</h2>
<div class="demo-info"> <p>The DataGrid toolbar can be defined from a &lt;div&gt; markup, so you can define the layout of toolbar easily.</p>
<div class="demo-tip icon-tip"></div> <div style="margin:20px 0;"></div>
<div>The DataGrid toolbar can be defined from a &lt;div/&gt; markup, so you can define the layout of toolbar easily.</div>
</div>
<div style="margin:10px 0;"></div>
<table class="easyui-datagrid" title="DataGrid Complex Toolbar" style="width:700px;height:250px" <table class="easyui-datagrid" title="DataGrid Complex Toolbar" style="width:700px;height:250px"
data-options="rownumbers:true,singleSelect:true,url:'datagrid_data1.json',method:'get',toolbar:'#tb'"> data-options="rownumbers:true,singleSelect:true,url:'datagrid_data1.json',method:'get',toolbar:'#tb',footer:'#ft'">
<thead> <thead>
<tr> <tr>
<th data-options="field:'itemid',width:80">Item ID</th> <th data-options="field:'itemid',width:80">Item ID</th>
...@@ -29,27 +26,25 @@ ...@@ -29,27 +26,25 @@
</tr> </tr>
</thead> </thead>
</table> </table>
<div id="tb" style="padding:5px;height:auto"> <div id="tb" style="padding:2px 5px;">
<div style="margin-bottom:5px"> Date From: <input class="easyui-datebox" style="width:110px">
<a href="#" class="easyui-linkbutton" iconCls="icon-add" plain="true"></a> To: <input class="easyui-datebox" style="width:110px">
<a href="#" class="easyui-linkbutton" iconCls="icon-edit" plain="true"></a> Language:
<a href="#" class="easyui-linkbutton" iconCls="icon-save" plain="true"></a> <select class="easyui-combobox" panelHeight="auto" style="width:100px">
<a href="#" class="easyui-linkbutton" iconCls="icon-cut" plain="true"></a> <option value="java">Java</option>
<a href="#" class="easyui-linkbutton" iconCls="icon-remove" plain="true"></a> <option value="c">C</option>
</div> <option value="basic">Basic</option>
<div> <option value="perl">Perl</option>
Date From: <input class="easyui-datebox" style="width:80px"> <option value="python">Python</option>
To: <input class="easyui-datebox" style="width:80px"> </select>
Language: <a href="#" class="easyui-linkbutton" iconCls="icon-search">Search</a>
<select class="easyui-combobox" panelHeight="auto" style="width:100px"> </div>
<option value="java">Java</option> <div id="ft" style="padding:2px 5px;">
<option value="c">C</option> <a href="#" class="easyui-linkbutton" iconCls="icon-add" plain="true"></a>
<option value="basic">Basic</option> <a href="#" class="easyui-linkbutton" iconCls="icon-edit" plain="true"></a>
<option value="perl">Perl</option> <a href="#" class="easyui-linkbutton" iconCls="icon-save" plain="true"></a>
<option value="python">Python</option> <a href="#" class="easyui-linkbutton" iconCls="icon-cut" plain="true"></a>
</select> <a href="#" class="easyui-linkbutton" iconCls="icon-remove" plain="true"></a>
<a href="#" class="easyui-linkbutton" iconCls="icon-search">Search</a>
</div>
</div> </div>
</body> </body>
</html> </html>
\ No newline at end of file
...@@ -11,13 +11,52 @@ ...@@ -11,13 +11,52 @@
</head> </head>
<body> <body>
<h2>Context Menu on DataGrid</h2> <h2>Context Menu on DataGrid</h2>
<div class="demo-info"> <p>Right click on the header of DataGrid to display context menu.</p>
<div class="demo-tip icon-tip"></div> <div style="margin:20px 0;"></div>
<div>Right click on the header of DataGrid to display context menu.</div>
</div>
<div style="margin:10px 0;"></div>
<table id="dg"></table> <table id="dg"></table>
<script type="text/javascript"> <script type="text/javascript">
(function($){
function buildMenu(target){
var state = $(target).data('datagrid');
if (!state.columnMenu){
state.columnMenu = $('<div></div>').appendTo('body');
state.columnMenu.menu({
onClick: function(item){
if (item.iconCls == 'tree-checkbox1'){
$(target).datagrid('hideColumn', item.name);
$(this).menu('setIcon', {
target: item.target,
iconCls: 'tree-checkbox0'
});
} else {
$(target).datagrid('showColumn', item.name);
$(this).menu('setIcon', {
target: item.target,
iconCls: 'tree-checkbox1'
});
}
}
})
var fields = $(target).datagrid('getColumnFields',true).concat($(target).datagrid('getColumnFields',false));
for(var i=0; i<fields.length; i++){
var field = fields[i];
var col = $(target).datagrid('getColumnOption', field);
state.columnMenu.menu('appendItem', {
text: col.title,
name: field,
iconCls: 'tree-checkbox1'
});
}
}
return state.columnMenu;
}
$.extend($.fn.datagrid.methods, {
columnMenu: function(jq){
return buildMenu(jq[0]);
}
});
})(jQuery);
$(function(){ $(function(){
$('#dg').datagrid({ $('#dg').datagrid({
url: 'datagrid_data1.json', url: 'datagrid_data1.json',
...@@ -38,47 +77,13 @@ ...@@ -38,47 +77,13 @@
]], ]],
onHeaderContextMenu: function(e, field){ onHeaderContextMenu: function(e, field){
e.preventDefault(); e.preventDefault();
if (!cmenu){ $(this).datagrid('columnMenu').menu('show', {
createColumnMenu();
}
cmenu.menu('show', {
left:e.pageX, left:e.pageX,
top:e.pageY top:e.pageY
}); });
} }
}); });
}); });
var cmenu;
function createColumnMenu(){
cmenu = $('<div/>').appendTo('body');
cmenu.menu({
onClick: function(item){
if (item.iconCls == 'icon-ok'){
$('#dg').datagrid('hideColumn', item.name);
cmenu.menu('setIcon', {
target: item.target,
iconCls: 'icon-empty'
});
} else {
$('#dg').datagrid('showColumn', item.name);
cmenu.menu('setIcon', {
target: item.target,
iconCls: 'icon-ok'
});
}
}
});
var fields = $('#dg').datagrid('getColumnFields');
for(var i=0; i<fields.length; i++){
var field = fields[i];
var col = $('#dg').datagrid('getColumnOption', field);
cmenu.menu('appendItem', {
text: col.title,
name: field,
iconCls: 'icon-ok'
});
}
}
</script> </script>
</body> </body>
</html> </html>
\ No newline at end of file
...@@ -11,11 +11,8 @@ ...@@ -11,11 +11,8 @@
</head> </head>
<body> <body>
<h2>Custom DataGrid Pager</h2> <h2>Custom DataGrid Pager</h2>
<div class="demo-info"> <p>You can append some buttons to the standard datagrid pager bar.</p>
<div class="demo-tip icon-tip"></div> <div style="margin:20px 0;"></div>
<div>You can append some buttons to the standard datagrid pager bar.</div>
</div>
<div style="margin:10px 0;"></div>
<table id="dg" title="Custom DataGrid Pager" style="width:700px;height:250px" <table id="dg" title="Custom DataGrid Pager" style="width:700px;height:250px"
data-options="rownumbers:true,singleSelect:true,pagination:true,url:'datagrid_data1.json',method:'get'"> data-options="rownumbers:true,singleSelect:true,pagination:true,url:'datagrid_data1.json',method:'get'">
<thead> <thead>
......
{"total":28,"rows":[
{"productid":"FI-SW-01","productname":"Koi","unitcost":"10.00","status":"P","listprice":"36.50","attr1":"Large","itemid":"EST-1"},
{"productid":"K9-DL-01","productname":"Dalmation","unitcost":"12.00","status":"P","listprice":"18.50","attr1":"Spotted Adult Female","itemid":"EST-10"},
{"productid":"RP-SN-01","productname":"Rattlesnake","unitcost":"12.00","status":"P","listprice":"38.50","attr1":"Venomless","itemid":"EST-11"},
{"productid":"RP-SN-01","productname":"Rattlesnake","unitcost":"12.00","status":"P","listprice":"26.50","attr1":"Rattleless","itemid":"EST-12"},
{"productid":"RP-LI-02","productname":"Iguana","unitcost":"12.00","status":"P","listprice":"35.50","attr1":"Green Adult","itemid":"EST-13"},
{"productid":"FL-DSH-01","productname":"Manx","unitcost":"12.00","status":"P","listprice":"158.50","attr1":"Tailless","itemid":"EST-14"},
{"productid":"FL-DSH-01","productname":"Manx","unitcost":"12.00","status":"P","listprice":"83.50","attr1":"With tail","itemid":"EST-15"},
{"productid":"FL-DLH-02","productname":"Persian","unitcost":"12.00","status":"P","listprice":"23.50","attr1":"Adult Female","itemid":"EST-16"},
{"productid":"FL-DLH-02","productname":"Persian","unitcost":"12.00","status":"P","listprice":"89.50","attr1":"Adult Male","itemid":"EST-17"},
{"productid":"AV-CB-01","productname":"Amazon Parrot","unitcost":"92.00","status":"P","listprice":"63.50","attr1":"Adult Male","itemid":"EST-18"}
]}
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Fluid DataGrid - jQuery EasyUI Demo</title>
<link rel="stylesheet" type="text/css" href="../../themes/default/easyui.css">
<link rel="stylesheet" type="text/css" href="../../themes/icon.css">
<link rel="stylesheet" type="text/css" href="../demo.css">
<script type="text/javascript" src="../../jquery.min.js"></script>
<script type="text/javascript" src="../../jquery.easyui.min.js"></script>
</head>
<body>
<h2>Fluid DataGrid</h2>
<p>This example shows how to assign percentage width to a column in DataGrid.</p>
<div style="margin:20px 0;"></div>
<table id="dg" class="easyui-datagrid" title="Fluid DataGrid" style="width:700px;height:250px"
data-options="singleSelect:true,collapsible:true,url:'datagrid_data1.json',method:'get'">
<thead>
<tr>
<th data-options="field:'itemid',resizable:false" width="15%">Item ID(15%)</th>
<th data-options="field:'productid',resizable:false" width="15%">Product(15%)</th>
<th data-options="field:'listprice',align:'right',resizable:false" width="15%">List Price(15%)</th>
<th data-options="field:'unitcost',align:'right',resizable:false" width="15%">Unit Cost(15%)</th>
<th data-options="field:'attr1',resizable:false" width="25%">Attribute(25%)</th>
<th data-options="field:'status',align:'center',resizable:false" width="15%">Status(15%)</th>
</tr>
</thead>
</table>
</body>
</html>
\ No newline at end of file
...@@ -11,11 +11,8 @@ ...@@ -11,11 +11,8 @@
</head> </head>
<body> <body>
<h2>Footer Rows in DataGrid</h2> <h2>Footer Rows in DataGrid</h2>
<div class="demo-info"> <p>The summary informations can be displayed in footer rows.</p>
<div class="demo-tip icon-tip"></div> <div style="margin:20px 0;"></div>
<div>The summary informations can be displayed in footer rows.</div>
</div>
<div style="margin:10px 0;"></div>
<table class="easyui-datagrid" title="Footer Rows in DataGrid" style="width:700px;height:220px" <table class="easyui-datagrid" title="Footer Rows in DataGrid" style="width:700px;height:220px"
data-options=" data-options="
url: 'datagrid_data2.json', url: 'datagrid_data2.json',
......
...@@ -11,11 +11,8 @@ ...@@ -11,11 +11,8 @@
</head> </head>
<body> <body>
<h2>Format DataGrid Columns</h2> <h2>Format DataGrid Columns</h2>
<div class="demo-info"> <p>The list price value will show red color when less than 30.</p>
<div class="demo-tip icon-tip"></div> <div style="margin:20px 0;"></div>
<div>The list price value will show red color when less than 30.</div>
</div>
<div style="margin:10px 0;"></div>
<table class="easyui-datagrid" title="Format DataGrid Columns" style="width:700px;height:250px" <table class="easyui-datagrid" title="Format DataGrid Columns" style="width:700px;height:250px"
data-options="rownumbers:true,singleSelect:true,iconCls:'icon-ok',url:'datagrid_data1.json',method:'get'"> data-options="rownumbers:true,singleSelect:true,iconCls:'icon-ok',url:'datagrid_data1.json',method:'get'">
<thead> <thead>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment