JQuery Grid BUG
Invoke the addrow method of the jqxGrid.
Author: http://jqwidgets.com
HTML
<script src="http://www.jqwidgets.com/jquery-widgets-demo/demos/jqxgrid/generatedata.js"></script>
<script src="http://jqwidgets.com/public/jqwidgets/jqx-all.js"></script>
<link rel="stylesheet" href="http://jqwidgets.com/public/jqwidgets/styles/jqx.base.css">
<link rel="stylesheet" href="http://jqwidgets.com/public/jqwidgets/styles/jqx.energyblue.css">
<div id='jqxWidget'>
<div id="jqxgrid"></div>
</div>
<div style="margin-top: 10px;">
<input id="addrowbutton" type="button" value="Add Row and Edit" />
</div>
JavaScript
// BUG when Add a new row, edit the first line, ENTER to save data and Add row again (duplicates firsts rows)
var data = generatedata(5);
var source = {
localdata: data,
datafields: [{
name: 'firstname',
type: 'string'
}, {
name: 'lastname',
type: 'string'
}, {
name: 'productname',
type: 'string'
}],
datatype: "array",
};
var adapter = new $.jqx.dataAdapter(source);
$("#jqxgrid").jqxGrid({
width: 500,
height: 500,
source: adapter,
sortable: true,
editable: true,
//editmode: 'selectedrow', // if not selected "selectrow" It's not possible to use beginrowedit, as it fails on saving
columns: [{
text: 'First Name',
datafield: 'firstname',
columngroup: 'Name',
}, {
text: 'Last Name',
columngroup: 'Name',
columntype: "combobox", //only have bug if selected "dropdownlist" or "combobox"
datafield: 'lastname',
}, {
text: 'Product',
datafield: 'productname'
}],
});
$("#addrowbutton").jqxButton({
height: 30
});
$("#addrowbutton").on('click', function () {
var datarow = generatedata(1)[0];
$("#jqxgrid").jqxGrid('addrow', null, {}, 'first'); // if we don't use "first" parameter, the bug don't show
setTimeout(function(){$("#jqxgrid").jqxGrid('beginrowedit', 0);}); //Needs timeout to work
});
$("#jqxgrid").on("sort", function (event)
{
$("#jqxgrid").jqxGrid('0', null, {}, 'first');
});