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 data grid - enables inline editing

Editable function recently added to the data grid (datagrid) of. It allows the user to add a new row to the data grid (datagrid). Users can also update one or more rows.

This tutorial shows you how to create a data grid (datagrid) and inline editor.

Creating a Data Grid (DataGrid)

	$ (Function () {
		$ ( '# Tt'). Datagrid ({
			title: 'Editable DataGrid',
			iconCls: 'icon-edit',
			width: 660,
			height: 250,
			singleSelect: true,
			idField: 'itemid',
			url: 'datagrid_data.json',
			columns: [[
				{Field: 'itemid', title: 'Item ID', width: 60},
				{Field: 'productid', title: 'Product', width: 100,
					formatter: function (value) {
						for (var i = 0; i <products.length; i ++) {
							if (products [i] .productid == value) return products [i] .name;
						}
						return value;
					},
					editor: {
						type: 'combobox',
						options: {
							valueField: 'productid',
							textField: 'name',
							data: products,
							required: true
						}
					}
				},
				{Field: 'listprice', title: 'List Price', width: 80, align: 'right', editor: {type: 'numberbox', options: {precision: 1}}},
				{Field: 'unitcost', title: 'Unit Cost', width: 80, align: 'right', editor: 'numberbox'},
				{Field: 'attr1', title: 'Attribute', width: 150, editor: 'text'},
				{Field: 'status', title: 'Status', width: 50, align: 'center',
					editor: {
						type: 'checkbox',
						options: {
							on: 'P',
							off: ''
						}
					}
				},
				{Field: 'action', title: 'Action', width: 70, align: 'center',
					formatter: function (value, row, index) {
						if (row.editing) {
							var s = '<a href="#" onclick="saverow(this)"> Save </a>';
							var c = '<a href="#" onclick="cancelrow(this)"> Cancel </a>';
							return s + c;
						} Else {
							var e = '<a href="#" onclick="editrow(this)"> Edit </a>';
							var d = '<a href="#" onclick="deleterow(this)"> Delete </a>';
							return e + d;
						}
					}
				}
			]],
			onBeforeEdit: function (index, row) {
				row.editing = true;
				updateActions (index);
			},
			onAfterEdit: function (index, row) {
				row.editing = false;
				updateActions (index);
			},
			onCancelEdit: function (index, row) {
				row.editing = false;
				updateActions (index);
			}
		});
	});
	function updateActions (index) {
		$ ( '# Tt'). Datagrid ( 'updateRow', {
			index: index,
			row: {}
		});
	}

To enable inline editing data grid, you should add a property to the editor column. Editor (editor) tells Data Grid (datagrid) How to edit the field and how to save the field value. As you can see, three editors (editor) We define: text, combobox and checkbox.

	function getRowIndex (target) {
		var tr = $ (target) .closest ( 'tr.datagrid-row');
		return parseInt (tr.attr ( 'datagrid-row-index'));
	}
	function editrow (target) {
		$ ( '# Tt') datagrid ( 'beginEdit', getRowIndex (target)).;
	}
	function deleterow (target) {
		$ .messager.confirm ( 'Confirm', 'Are you sure?', Function (r) {
			if (r) {
				$ ( '# Tt') datagrid ( 'deleteRow', getRowIndex (target)).;
			}
		});
	}
	function saverow (target) {
		$ ( '# Tt') datagrid ( 'endEdit', getRowIndex (target)).;
	}
	function cancelrow (target) {
		$ ( '# Tt') datagrid ( 'cancelEdit', getRowIndex (target)).;
	}

Download jQuery EasyUI examples

jeasyui-datagrid-datagrid12.zip