Html Grid
Set the columns property of the jqxGrid.
Author: http://jqwidgets.com
HTML
<script src="https://jqwidgets.com/public/jqwidgets/jqx-all.js"></script>
<link rel="stylesheet" href="https://jqwidgets.com/public/jqwidgets/styles/jqx.base.css">
<link rel="stylesheet" href="https://jqwidgets.com/public/jqwidgets/styles/jqx.energyblue.css">
<script src="https://jqwidgets.com/jquery-widgets-demo/demos/jqxgrid/generatedata.js"></script>
<div id='jqxWidget'>
<div id="jqxgrid"></div>
</div>
JavaScript
var data = generatedata(50);
data[0].quantity = null;
var source = {
localdata: data,
datafields: [{
name: 'firstname',
type: 'string'
}, {
name: 'lastname',
type: 'string'
}, {
name: 'productname',
type: 'string'
}, {
name: 'date',
type: 'date'
}, {
name: 'quantity',
type: 'number'
}, {
name: 'price',
type: 'number'
}],
datatype: "array"
};
var defaultValue = '';
var isPossible = false;
var currentRow = -1;
var activeEditor = null;
var adapter = new $.jqx.dataAdapter(source);
$("#jqxgrid").jqxGrid({
width: 500,
theme: 'energyblue',
source: adapter,
editable: true,
columns: [{
text: 'First Name',
datafield: 'firstname',
width: 90
}, {
text: 'Quantity',
datafield: 'quantity',
width: 170,
align: 'right',
cellsalign: 'right',
columntype: 'numberinput',
validation: function (cell, value) {
if (value < 0 || value > 150) {
return {
result: false,
message: "Quantity should be in the 0-150 interval"
};
}
return true;
},
initeditor: function (row, cellvalue, editor, celltext, pressedChar) {
if (cellvalue == null) {
editor.find('input')[0].value = "";
}
activeEditor = editor;
},
createeditor: function (row, cellvalue, editor) {
if (cellvalue == null) {
editor.find('input')[0].value = "";
}
},
cellvaluechanging: function (row, datafield, columntype, oldvalue, newvalue) {
if (activeEditor && activeEditor.find('input')[0].value == "")
return "";
},
}, {
text: 'Price',
datafield: 'price',
width: 90,
cellsformat: 'c2'
},...