Latest web development tutorials
×

jQuery EasyUI Tutorial

jQuery EasyUI Tutorial jQuery EasyUI Introduction

jEasyUI application

jEasyUI Create a CRUD application jEasyUI Create a CRUD data grid jEasyUI Form CRUD application jEasyUI Create an RSS reader

jEasyUI Drag and drop

jEasyUI Basic drag and drop jEasyUI Create a drag-and-drop shopping cart jEasyUI Create a school curriculum

jEasyUI Menus and buttons

jEasyUI Create a simple menu jEasyUI Create a link button jEasyUI Create a menu button jEasyUI Create a split button

jEasyUI layout

jEasyUI Create a border layout jEasyUI Create a complex layout jEasyUI Creates a fold panel jEasyUI Create a tab page jEasyUI Dynamically add a tab jEasyUI Add the AutoPlay tab jEasyUI Create the XP style left panel

jEasyUI Data grid

jEasyUI Convert HTML tables to data grids jEasyUI Get the selected row data jEasyUI Add the query function jEasyUI Add a toolbar jEasyUI Create complex toolbars jEasyUI Sets the frozen column jEasyUI Dynamically change columns jEasyUI Format the column jEasyUI Set sort jEasyUI Custom sorting jEasyUI Create a column combination jEasyUI Add a check box jEasyUI Custom tab jEasyUI Enable in-line editing jEasyUI Extension editor jEasyUI Column operation jEasyUI Merge Cells jEasyUI Create a custom view jEasyUI Create a footer summary jEasyUI Condition Sets the line background color jEasyUI Create an attribute grid jEasyUI The extended line shows the details jEasyUI Create a subgrid jEasyUI Display massive data jEasyUI Add a paging component

jEasyUI window

jEasyUI Create a simple window jEasyUI Customize the Window Toolbar jEasyUI Window and layout jEasyUI Create a dialog box jEasyUI Customize the dialog box

jEasyUI Tree menu

jEasyUI Use the markup to create a tree menu jEasyUI Create an asynchronous tree menu jEasyUI Tree menu to add nodes jEasyUI Create a tree menu with check boxes jEasyUI Tree menu drag and drop control jEasyUI The Tree menu loads the parent / child nodes jEasyUI Create the base tree grid jEasyUI Create a complex tree grid jEasyUI Dynamic loading of tree jEasyUI The tree grid adds pagination jEasyUI Tree-lazy lazy-loading node

jEasyUI Form

jEasyUI Create an asynchronous submission form jEasyUI Form validation jEasyUI Create a tree drop-down box jEasyUI Format the drop-down box jEasyUI Filter down the data grid

jEasyUI Reference Manual

jQuery EasyUI Plugin jQuery EasyUI Extended

jQuery EasyUI extension - editable data grid

jQuery EasyUI Extended jQuery EasyUI Extended

usage

Creating a Data Grid (datagrid) in html tag

	<Table id = "tt" style = "width: 600px; height: 200px"
			title = "Editable DataGrid"
			singleSelect = "true">
		<Thead>
			<Tr>
				<Th field = "itemid" width = "100" editor = "{type: 'validatebox', options: {required: true}}"> Item ID </ th>
				<Th field = "productid" width = "100" editor = "text"> Product ID </ th>
				<Th field = "listprice" width = "100" align = "right" editor = "{type: 'numberbox', options: {precision: 1}}"> List Price </ th>
				<Th field = "unitcost" width = "100" align = "right" editor = "numberbox"> Unit Cost </ th>
				<Th field = "attr1" width = "150" editor = "text"> Attribute </ th>
			</ Tr>
		</ Thead>
	</ Table>

Let Data Grid (datagrid) editable

$ ( '# Tt'). Edatagrid ({
    url: 'datagrid_data.json',
    saveUrl: ...,
    updateUrl: ...,
    destroyUrl: ...
});

Now you can double-click on the data grid row start editing. You can also set saveUrl, updateUrl, destroyUrl property to automatically synchronize the client and server-side data.

Attributes

The property extends from the data grid (datagrid), the following attributes are editable data grid (edatagrid) added.

名称 类型 描述 默认值
destroyMsg object 当销毁一行时要显示的确认对话框消息。
destroyMsg:{
	norecord:{	// when no record is selected
		title:'Warning',
		msg:'No record is selected.'
	},
	confirm:{	// when select a row
		title:'Confirm',
		msg:'Are you sure you want to delete?'
	}
}
autoSave boolean 设置为 true,则当点击数据网格外部时自动保存编辑行。 false
url string 一个 URL,从服务器检索数据。 null
saveUrl string 一个 URL,向服务器保存数据,并返回添加的行。 null
updateUrl string 一个 URL,向服务器更新数据,并返回更新的行。 null
destroyUrl string 一个 URL,向服务器传送 'id' 参数来销毁该行。 null
tree selector 显示对应的树组件的树选择器。 null
treeUrl string 一个 URL,检索树的数据。 null
treeDndUrl string 一个 URL,处理拖放操作。 null
treeTextField string 定义树的文本字段名称。 name
treeParentField string 定义树的父节点字段名称。 parentId

event

The event extended from the data grid (datagrid), the following events are editable data grid (edatagrid) added.

名称 参数 描述
onAdd index,row 当添加一个新行时触发。
onEdit index,row 当编辑一行时触发。
onBeforeSave index 一行被保存之前触发,返回 false 则取消保存动作。
onSave index,row 当保存一行时触发。
onDestroy index,row 当销毁一行时触发。
onError index,row 当发生服务器错误时触发。
服务器应返回一个 'isError' 属性设置为 true 的行,表示发生错误。

代码实例:

//server side code
echo json_encode(array(
	'isError' => true,
	'msg' => 'error message.'
));
//client side code
$('#dg').edatagrid({
	onError: function(index,row){
		alert(row.msg);
	}
});

method

The methods extend from the data grid (datagrid), the following are editable data grid (edatagrid) add or override methods.

名称 参数 描述
options none 返回选项(options)对象。
enableEditing none 启用数据网格(datagrid)编辑。
disableEditing none 禁用数据网格(datagrid)编辑。
editRow index 编辑指定的行。
addRow index 向指定的行索引添加一个新行。
如果 index 参数未指定,则向最后的位置追加一个新行。

代码实例:

// append an empty row
$('#dg').edatagrid('addRow');

// append an empty row as first row
$('#dg').edatagrid('addRow',0);

// insert a row with default values
$('#dg').edatagrid('addRow',{
	index: 2,
	row:{
		name:'name1',
		addr:'addr1'
	}
});
saveRow none 保存编辑行,发布到服务器。
cancelRow none 取消编辑行。
destroyRow index 销毁当前选中的行。
如果 index 参数未指定,则销毁所有选中的行。

代码实例:

// destroy all the selected rows
$('#dg').edatagrid('destroyRow');

// destroy the first row
$('#dg').edatagrid('destroyRow', 0);

// destroy the specified rows
$('#dg').edatagrid('destroyRow', [3,4,5]);

Download jQuery EasyUI examples

jquery-easyui-edatagrid.zip


jQuery EasyUI Extended jQuery EasyUI Extended