JSFiddle - React, Tailwind, and code Playground
HTML
<link rel="stylesheet" href="http://www.jeasyui.com/easyui/themes/default/easyui.css">
<script src="http://www.jeasyui.com/easyui/jquery.easyui.min.js"></script>
<script src="http://www.jeasyui.com/easyui/datagrid-detailview.js"></script>
<script src="http://www.jeasyui.com/easyui/datagrid-filter.js"></script>
<input type="text" name="subInput" id="subInput" maxlength="24" class="form-control" placeholder="Numer listy">
<table id="tt"></table>
Simple table
<table id="simple"></table>
JavaScript
$('#tt').datagrid({
title:'DataGrid - DetailView',
width:500,
height:250,
remoteSort:false,
singleSelect:true,
nowrap:false,
fitColumns:true,
columns:[[
{field:'itemid',title:'Item ID',width:80},
{field:'productid',title:'Product ID',width:100,sortable:true,editor:'text'},
{field:'productid',title:'Action',width:100}
]],
view: detailview
});
$('#tt').datagrid('enableFilter');
$(document).ready(function(){
var rowNum = 0;
function addDetails() {
rowNum ++;
var row = '<tr id="rowNum'+rowNum+'"><td class="ui-widget-content first">'+rowNum+'</td><td id="tblAppendGrid_Numer_td_'+rowNum+'" class="ui-widget-content first"><p >'+$('#subInput').val()+'</p></td><td class="ui-widget-content last"><input type="button" value="Delete" id="'+rowNum+'" class="removeRow button-sml"><i class="fa fa-trash-o"></i><input type="hidden" id="tblAppendGrid_Numer_'+rowNum+'" value="'+$('#subInput').val()+'" name="tblAppendGrid_Numer_'+rowNum+'"></td></tr>';
$('#tt').append(row);
$('#simple').append(row);
console.log(row);
return false;
};
//
$(document).on('click', '.removeRow', function() {
$('#rowNum'+this.id).remove();
});
$("#subInput").keydown(function(event){
if ( event.keyCode == 46 || event.keyCode == 8 ) {
// let it happen, don't do anything
}else if (event.keyCode < 48 || event.keyCode > 57 ) {
event.preventDefault();
}
var remainingChars = $(this).val().length;
if (remainingChars == 24) {
addDetails();
$(this).val(''); // does empty the text input
}
});
});