import * as React from 'react'; import JqxDataTable, { IDataTableProps, jqx } from 'jqwidgets-scripts/jqwidgets-react-tsx/jqxdatatable'; class App extends React.PureComponent<{}, IDataTableProps> { private log = React.createRef(); constructor(props: {}) { super(props); this.onCellBeginEdit = this.onCellBeginEdit.bind(this); this.onCellEndEdit = this.onCellEndEdit.bind(this); const source: any = { dataFields: [ { name: 'OrderID', type: 'int' }, { name: 'Freight', type: 'float' }, { name: 'ShipName', type: 'string' }, { name: 'ShipAddress', type: 'string' }, { name: 'ShipCity', type: 'string' }, { name: 'ShipCountry', type: 'string' }, { name: 'ShippedDate', type: 'date' } ], dataType: 'xml', id: 'OrderID', record: 'Order', root: 'Orders', url: 'orderdetails.xml' }; this.state = { columns: [ { text: 'Freight', dataField: 'Freight', cellsFormat: 'f', cellsAlign: 'right', align: 'right', width: 250 }, { text: 'Ship Country', dataField: 'ShipCountry', width: 250 }, { text: 'Shipped Date', dataField: 'ShippedDate', cellsAlign: 'right', align: 'right', cellsFormat: 'dd/MM/yyyy' } ], editSettings: { cancelOnEsc: true, editOnDoubleClick: true, editOnF2: true, editSingleCell: true, saveOnBlur: true, saveOnEnter: true, saveOnPageChange: true, saveOnSelectionChange: true }, source: new jqx.dataAdapter(source) }; } public render() { return (

Event Log

); } private onCellBeginEdit(event: any): void { const args = event.args; // row's index. const rowIndex = args.index; // column's data field. const columnDataField = args.dataField; // cell's value. let value = args.value; if (columnDataField === 'ShippedDate' && value) { value = value.getDate() + '/' + parseInt((value.getMonth() + 1), 10) + '/' + value.getFullYear(); } const log = this.log.current!; log.innerHTML = 'cellBeginEdit - Row: ' + rowIndex + ', Column: ' + columnDataField + ', Value: ' + value + '
' + log.innerHTML; } private onCellEndEdit(event: any): void { const args = event.args; // row's index. const rowIndex = args.index; // column's data field. const columnDataField = args.dataField; // cell's value. let value = args.value; if (columnDataField === 'ShippedDate' && value) { value = value.getDate() + '/' + parseInt((value.getMonth() + 1), 10) + '/' + value.getFullYear(); } const log = this.log.current!; log.innerHTML = '
cellEndEdit - Row: ' + rowIndex + ', Column: ' + columnDataField + ', Value: ' + value + '
' + log.innerHTML; } } export default App;