JSFiddle - React, Tailwind, and code Playground

by andruxnet

HTML

<link rel="stylesheet" href="http://www.jeasyui.com/easyui/themes/default/easyui.css">
<link rel="stylesheet" href="http://www.jeasyui.com/easyui/themes/icon.css">
<link rel="stylesheet" href="http://www.jeasyui.com/easyui/demo/demo.css">
<script src="http://www.jeasyui.com/easyui/jquery.easyui.min.js"></script>
<script src="http://wptest.andrux.net/jquery.edatagrid.js"></script>
<table id="roles-permissions"></table>
<script>
   function updateActions( index ) {
	jQuery( '#roles-permissions' ).datagrid( 'updateRow', {
		index: index,
		row: {}
	});
}

function getRowIndex( target ) {
	var tr = jQuery( target ).closest( 'tr.datagrid-row' );
	return parseInt( tr.attr( 'datagrid-row-index' ) );
}

function editrow( target ) {
	jQuery( '#roles-permissions' ).edatagrid( 'editRow', getRowIndex( target ) );
}

function saverow( target ) {
	jQuery( '#roles-permissions' ).datagrid( 'endEdit', getRowIndex( target ) );
}

function cancelrow( target ) {
	jQuery( '#roles-permissions' ).datagrid( 'cancelEdit', getRowIndex( target ) );
}
</script>

JavaScript

jQuery( document ).ready( function( $ ) {
	/* manage editing role permissions datagrid */
	$( '#roles-permissions' ).edatagrid({
		title: 'Role Permissions',
		//url: ajaxurl + '?action=settings_get_roles&query_id=' + queryId,
		//updateUrl: ajaxurl + '?action=settings_update_role&query_id=' + queryId,
		iconCls: 'icon-edit',
		width: 420,
		height: 240,
		singleSelect: true,
		idField: 'role',
		columns:[[
			{field: 'role', title: 'Role', width: 100},
			{field: 'view', title: 'View', width: 50, align: 'center',
				editor: {
					type: 'checkbox',
					options: {
						on: 'yes',
						off: 'no'
					}
				}
			},
			{field: 'edit', title: 'Edit', width: 50, align: 'center',
				editor: {
					type: 'checkbox',
					options: {
						on: 'yes',
						off: 'no'
					}
				}
			},
			{field: 'remove', title: 'Remove', width: 50, align: 'center',
				editor: {
					type: 'checkbox',
					options: {
						on: 'yes',
						off: 'no'
					}
				}
			},
			{field: 'action', title: 'Action', width: 80, align: 'center',
				formatter: function( value, row, index ) {
					if ( row.editing ) {
						var s = '<a class="icon-save" style="text-decoration: none; padding: 0px 5px;" href="#" onclick="saverow( this )">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</a> ';
						var c = '<a class="icon-cancel" style="text-decoration: none; padding: 0px 5px;" href="#" onclick="cancelrow( this )">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</a>';
						return s + c;
					}
					else {
						var e = '<a class="icon-edit" style="text-decoration: none; padding: 0px 5px;" href="#" onclick="editrow(this)">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</a> ';
						return e;
					}
				}
			}
		]],
		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 );
		},
		onEdit: function( index, row )...