你好,这个问题实际上就是原生Wijmo input组件加快捷键的问题,
思路就是通过给嵌入到WijmoFlexGrid中的原生input组件添加键盘事件就可以实现,
参考:
https://demo.grapecity.com.cn/wi ... tNumber/Step/purejs
把app.js替换为以下代码就可以看到效果:
- import 'bootstrap.css';
- import '@grapecity/wijmo.styles/wijmo.css';
- import './styles.css';
- //
- import * as wijmo from '@grapecity/wijmo';
- import * as input from '@grapecity/wijmo.input';
- //
- document.readyState === 'complete' ? init() : window.onload = init;
- //
- function init() {
- // create several InputNumber controls and assign them formats
- let parent = document.getElementById('inputNumbers'), template = '<div class="form-group">' +
- '<label for={id}>Step {step}: </label>' +
- '<input id={id}>' +
- '</div>';
- //
- ['n0', 'n2', 'c0', 'c2', 'p0', 'p2'].forEach((fmt, i) => {
- let id = 'theInputNumberF' + fmt, step = fmt[0] == 'p' ? 0.1 : (i + 1), html = wijmo.format(template, {
- fmt: fmt,
- id: id,
- step: step
- });
- //
- parent.appendChild(wijmo.createElement(html));
- let theNumber = new input.InputNumber('#' + id, {
- format: fmt,
- step: step
- });
- theNumber.hostElement.addEventListener('keydown', function (e) {
-
- if (e.keyCode == wijmo.Key.Down) {
- //
- e.preventDefault();
- //
- alert("Down");
- }
-
- if (e.keyCode == wijmo.Key.Up) {
- //
- e.preventDefault();
- //
- alert("Up");
- }
- }, true);
- });
- }
复制代码 |