TableEditor

Flexible in place editing of TableSorter


RESTORE EXAMPLE

« Back to main page

This example demonstrates the restoreRow() function. This is useful if your AJAX update failed and the values (in table) should be restored to the original. NOTE: every other request will fail.

$.tableEditor.lib.restoreRow(o.row,o.original); is used within the update function to restore the row

ID First Name Last Name Phone City Email
233 XXX
1 Brice Burgess (800)768-5283 Milwaukee b@b.com
2 Christian Bach (800)768-6288 Chicago c@c.com
3 Abe Lincoln (800)223-2331 Washington D.C. l@l.com
8 Sam Lightning Hopkings (800)728-1221 Houston s@s.com
15 Rudyard Kipling (512)121-1280 London r@r.com

SOURCE

<script type="text/javascript">
$().ready(function() {	
	$("#editableTable").tableSorter({ 
		sortClassAsc: 'headerSortUp', 		// class name for ascending sorting action to header
		sortClassDesc: 'headerSortDown',	// class name for descending sorting action to header
		headerClass: 'header', 				// class name for headers (th's)
		disableHeader: 'ID' 	// DISABLE Sorting on ID
	}).tableEditor({
		EDIT_HTML: 'edit',
		SAVE_HTML: 'save',
		EVENT_LINK_SELECTOR: 'button.eventLink',
		FUNC_UPDATE: 'updateTable'
	});
	
	document.counter = 0;
});

function updateTable(o) {
	document.counter++;
	
	if ((document.counter%2) == 0) {
		// restore row
		alert('Update failed. Row restore.');
		$.tableEditor.lib.restoreRow(o.row,o.original);
	}
	else
		alert('Update Success');
		
	return true;
}
</script>


(c) 2006 - Brice Burgess