第二个Demo即可满足条件,参考以下代码:
- import 'bootstrap.css';
- import '@grapecity/wijmo.styles/wijmo.css';
- import './styles.css';
- import * as wjGrid from '@grapecity/wijmo.grid';
- import * as wjInput from '@grapecity/wijmo.input';
- import * as wjCore from '@grapecity/wijmo';
- import { getData } from './data';
- //
- document.readyState === 'complete' ? init() : window.onload = init;
- //
- function init() {
- //
- // create the grid
- var theGrid = new wjGrid.FlexGrid('#theGrid', {
- itemsSource: getData(),
- allowAddNew: true
- });
- //
- // use ctrl+Delete to delete the current row
- var theDialog = new wjInput.Popup('#theDialog');
- theGrid.hostElement.addEventListener('keydown', function (e) {
- var view = theGrid.collectionView;
- //
- // looking for ctrl+Delete
- if (e.keyCode == wjCore.Key.Enter && view.currentItem) {
- //
- // prevent the grid from getting the key
- e.preventDefault();
- //
- console.log(theGrid.selection);
- theGrid.select(theGrid.selection.row, theGrid.selection.col +3);
- }
- }, true);
- }
复制代码
替换掉第二个Demo的app.js即可看到效果。
注意,这段代码仅演示实现逻辑,没有判断总列数,请结合自己的业务逻辑加判断。 |