你好,请参考这个示例:
https://demo.grapecity.com.cn/wi ... nding/Basics/purejs
将以下代码完整替换掉app.js即可看到效果:
- import 'bootstrap.css';
- import '@grapecity/wijmo.styles/wijmo.css';
- import { SortDescription, format } from '@grapecity/wijmo';
- import { FlexGrid } from '@grapecity/wijmo.grid';
- document.readyState === 'complete' ? init() : window.onload = init;
- function init() {
- // create some random data
- var countries = 'US,Germany,UK,Japan,Italy,Greece'.split(',');
- var data = [];
- for (var i = 0; i < countries.length; i++) {
- data.push({
- id: i,
- country: "20-06-03 15:27",
- sales: '20-06-03 15:27',
- expenses: '20-06-03 15:27'
- });
- }
- // bind a grid to the raw data
- var theGrid = new FlexGrid('#theGrid', {
- allowSorting: false,
- showSort: false,
- autoGenerateColumns: false,
- columns: [
- { binding: 'country', header: 'Country', width: '2*' },
- { binding: 'sales', header: 'Sales', width: '*'},
- { binding: 'expenses', header: 'Expenses', width: '*'}
- ],
- itemsSource: data
- });
- // show the current item
- var selItemElement = document.getElementById('selectedItem');
- function updateCurrentInfo() {
- selItemElement.innerHTML = format('Country: <b>{country}</b>, Sales: <b>{sales:c0}</b> Expenses: <b>{expenses:c0}</b>', theGrid.collectionView.currentItem);
- }
- // update current item now and when the grid selection changes
- updateCurrentInfo();
- theGrid.collectionView.currentChanged.addHandler(updateCurrentInfo);
- // sort the data by country
- var sd = new SortDescription('country', true);
- theGrid.collectionView.sortDescriptions.push(sd);
- }
复制代码 |