jQuery EasyUI DataGrid combogrid editor
HTML
<h2>Datagrid with Combogrid editor</h2>
<p>We use a datagrid and a combogrid as editor for the servername. The combogrid has a big data list so we use the "Datagrid Scroll View" extension inside the combogrid.
</p>
<div class="easyui-panel" style="width:100%; height:400px; padding:12px;">
<table id="dg"></table>
</div>
CSS
</style>
<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.easyui.min.js"></script>
<script type="text/javascript" src="http://www.jeasyui.com/easyui/jquery.edatagrid.js"></script>
<script type="text/javascript" src="http://www.jeasyui.com/easyui/datagrid-scrollview.js"></script>
<style>
JavaScript
$(function(){
var dg = $('#dg').edatagrid();
dg.edatagrid({
title:"edatagrid with combogrid editor",
fit:true, pagination: true, singleSelect:true, striped:true, rownumbers: true, fitColumns: true,
data:gridData,
columns:[[
{field:'server', title:'servername', width:200,
formatter:function(value,row){
return row.serverName || value;
},
editor:{
type:'combogrid',
options:{
prompt: 'Server ...',
rownumbers: true,
singleSelect:true,
autoRowHeight:false,
panelHeight: 160,
view:scrollview,
pageSize: 5,
idField:'value',
textField:'text',
data: $.extend(true,[],data),
columns:[[
{field:'text', title:'Servername', width: 250}
]],
loadFilter: function(data){
//the following code is important to fix a problem with loadfilter!
if ($.isArray(data)){
data = {
total:data.length,
rows:data
};
}
return data;
},
onFetch: function(page, rows){
console.log('onFetch page: ' + page);
//consoleDebug(rows);
},
onShowPanel: function() {
console.log('onShowPanel ...');
var value = $(this).combogrid('getValue');
var grid = $(this).combogrid('grid');
var gOpts = grid.datagrid('options');
var rows = grid.datagrid('getData').firstRows;
var index = findIndex();
if (index >= 0){
grid.datagrid('scrollTo', index);
...