UNPKG

jqwidgets-framework

Version:

jQWidgets is an advanced jQuery, Angular, React, ASP .NET MVC, Custom Elements and HTML5 UI framework.

58 lines (50 loc) 2.4 kB
import React from 'react'; import ReactDOM from 'react-dom'; import JqxGrid from '../../../jqwidgets-react/react_jqxgrid.js'; import JqxButton from '../../../jqwidgets-react/react_jqxbuttons.js'; class App extends React.Component { componentDidMount() { this.refs.myButton.on('click', () => { this.refs.myGrid.autoresizecolumns(); }); } render() { let source = { datatype: 'xml', datafields: [ { name: 'ShippedDate', map: 'm\\:properties>d\\:ShippedDate', type: 'date' }, { name: 'Freight', map: 'm\\:properties>d\\:Freight', type: 'float' }, { name: 'ShipName', map: 'm\\:properties>d\\:ShipName', type: 'string' }, { name: 'ShipAddress', map: 'm\\:properties>d\\:ShipAddress', type: 'string' }, { name: 'ShipCity', map: 'm\\:properties>d\\:ShipCity', type: 'string' }, { name: 'ShipCountry', map: 'm\\:properties>d\\:ShipCountry', type: 'string' } ], root: 'entry', record: 'content', id: 'm\\:properties>d\\:OrderID', url: '../sampledata/orders.xml' }; let dataAdapter = new $.jqx.dataAdapter(source); let columns = [ { text: 'Ship Name', datafield: 'ShipName', width: 50 }, { text: 'Shipped Date', datafield: 'ShippedDate', width: 30, cellsformat: 'D' }, { text: 'Freight', datafield: 'Freight', width: 30, cellsformat: 'F2', cellsalign: 'right' }, { text: 'Ship Address', datafield: 'ShipAddress', width: 50 }, { text: 'Ship City', datafield: 'ShipCity', width: 100 }, { text: 'Ship Country', datafield: 'ShipCountry' } ]; return ( <div style={{ fontSize: 13, fontFamily: 'Verdana', float: 'left' }}> <JqxGrid ref='myGrid' width={850} source={dataAdapter} columns={columns} /> <div style={{ marginTop: 30 }}> <JqxButton ref='myButton' value='Auto Resize Columns' /> </div> </div> ) } } ReactDOM.render(<App />, document.getElementById('app'));