你好,可以监听CellEditEnded事件,判断一下绑定列或值得类型即可,参考以下代码:
- 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: countries[i],
- sales: Math.random() * 10000,
- expenses: Math.random() * 5000,
- bool: true
- });
- }
- // bind a grid to the raw data
- var theGrid = new FlexGrid('#theGrid', {
- autoGenerateColumns: false,
- columns: [
- { binding: 'country', header: 'Country', width: '2*' },
- { binding: 'sales', header: 'Sales', width: '*', format: 'n2' },
- { binding: 'expenses', header: 'Expenses', width: '*', format: 'n2' },
- { binding: 'bool', header: 'Bool'}
- ],
- itemsSource: data,
- cellEditEnded: (s, e) => {
- console.log(s, e)
- }
- });
- // 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);
- }
复制代码
把上述代码放到实例的app.js里即可看到效果:
https://www.grapecity.com/wijmo/ ... nding/Basics/purejs
注意看控制台,打印的参数内容中有你需要的信息。 |