JSFiddle - React, Tailwind, and code Playground

by Dmitriy Seliverstov

HTML

<link rel="stylesheet" href="https://www.jeasyui.com/easyui/themes/default/easyui.css">
<link rel="stylesheet" href="https://www.jeasyui.com/easyui/themes/icon.css">
<link rel="stylesheet" href="https://www.jeasyui.com/easyui/themes/color.css">
<script src="https://code.jquery.com/jquery-1.9.1.min.js"></script>
<script src="https://www.jeasyui.com/easyui/jquery.easyui.min.js"></script>
<script src="https://www.jeasyui.com/easyui/datagrid-cellediting.js"></script>
<title>Cell Editing in DataGrid - jQuery EasyUI Demo</title>
<h2>Cell Editing in DataGrid</h2>
<p>Click a cell to start editing.</p>

<div style="margin:20px 0;"></div>

<table id="dg" title="Cell Editing in DataGrid" style="width:700px;height:200px">
    <thead>
    <tr>
        <th data-options="field:'itemid',width:50">Item ID</th>
        <th data-options="field:'productname',width:340, editor:'product'">Product name</th>
        <th data-options="field:'measure',width:60,align:'center',editor:{
            type:'combobox',options:{valueField: 'name', textField:'name', data: [
		                            {id: 1, name: 'pcs'},
                                {id: 2, name: 'wth'},
                                {id: 3, name: 'vol'},
	                                                ]}}">Measure</th>
        <th data-options="field:'price',width:60,align:'right',editor:{type:'numberbox',options:{precision:2}}">Price
        </th>
        <th data-options="field:'quantity',width:60,align:'right',editor:'numberbox'">Quantity</th>
        <th data-options="field:'total',width:60,align:'right',editor:'numberbox'">Total</th>
        <th data-options="field:'attr1',width:50,editor:'text',align:'center'">Attribute</th>
    </tr>
    </thead>
</table>

    <div id="dd" class="easyui-dialog" style="padding:0px;width:620px;height:400px;"
         data-options="modal:'true', closed:'true'"
         title="My Dialog" iconCls="icon-ok"
         toolbar="#dlg-toolbar" buttons="#dlg-buttons">
         <table id="tg"...

JavaScript

(function ($) {
    $.extend($.fn.datagrid.defaults, {
        clickToEdit: false,
        dblclickToEdit: true,
        navHandler: {
            '37': function (e) {
                var opts = $(this).datagrid('options');
                return navHandler.call(this, e, opts.isRtl ? 'right' : 'left');
            },
            '39': function (e) {
                var opts = $(this).datagrid('options');
                return navHandler.call(this, e, opts.isRtl ? 'left' : 'right');
            },
            '38': function (e) {
                return navHandler.call(this, e, 'up');
            },
            '40': function (e) {
                return navHandler.call(this, e, 'down');
            },
            '13': function (e) {
                return enterHandler.call(this, e);
            },
            '27': function (e) {
                return escHandler.call(this, e);
            },
            '8': function (e) {
                return clearHandler.call(this, e);
            },
            '46': function (e) {
                return clearHandler.call(this, e);
            },
            'keypress': function (e) {
                if (e.metaKey || e.ctrlKey) {
                    return;
                }
                var dg = $(this);
                var param = dg.datagrid('cell');	// current cell information
                if (!param) {
                    return;
                }
                var input = dg.datagrid('input', param);
                if (!input) {
                    var tmp = $('<span></span>');
                    tmp.html(String.fromCharCode(e.which));
                    var c = tmp.text();
                    tmp.remove();
                    if (c) {
                        dg.datagrid('editCell', {
                            index: param.index,
                            field: param.field,
                            value: c
                        });
                        return false;
                    }
    ...