找回密码
 立即注册

QQ登录

只需一步,快速开始

醉汀雨笙

金牌服务用户

21

主题

93

帖子

336

积分

金牌服务用户

积分
336

微信认证勋章

醉汀雨笙
金牌服务用户   /  发表于:2020-12-28 16:21  /   查看:3418  /  回复:5
1金币
grid單元格如何使用enter 鍵跳轉到該單元格的后三個單元格。

最佳答案

查看完整内容

第二个Demo即可满足条件,参考以下代码: 替换掉第二个Demo的app.js即可看到效果。 注意,这段代码仅演示实现逻辑,没有判断总列数,请结合自己的业务逻辑加判断。

5 个回复

倒序浏览
最佳答案
最佳答案
KevinChen讲师达人认证 悬赏达人认证 SpreadJS 开发认证
论坛元老   /  发表于:2020-12-28 16:21:55
来自 4#
第二个Demo即可满足条件,参考以下代码:

  1. import 'bootstrap.css';
  2. import '@grapecity/wijmo.styles/wijmo.css';
  3. import './styles.css';
  4. import * as wjGrid from '@grapecity/wijmo.grid';
  5. import * as wjInput from '@grapecity/wijmo.input';
  6. import * as wjCore from '@grapecity/wijmo';
  7. import { getData } from './data';
  8. //
  9. document.readyState === 'complete' ? init() : window.onload = init;
  10. //
  11. function init() {
  12.     //
  13.     // create the grid
  14.     var theGrid = new wjGrid.FlexGrid('#theGrid', {
  15.         itemsSource: getData(),
  16.         allowAddNew: true
  17.     });
  18.     //
  19.     // use ctrl+Delete to delete the current row
  20.     var theDialog = new wjInput.Popup('#theDialog');
  21.     theGrid.hostElement.addEventListener('keydown', function (e) {
  22.         var view = theGrid.collectionView;
  23.         //
  24.         // looking for ctrl+Delete
  25.         if (e.keyCode == wjCore.Key.Enter && view.currentItem) {
  26.             //
  27.             // prevent the grid from getting the key
  28.             e.preventDefault();
  29.             //
  30.             console.log(theGrid.selection);
  31.             theGrid.select(theGrid.selection.row, theGrid.selection.col +3);
  32.         }
  33.     }, true);
  34. }
复制代码


替换掉第二个Demo的app.js即可看到效果。

注意,这段代码仅演示实现逻辑,没有判断总列数,请结合自己的业务逻辑加判断。
回复 使用道具 举报
KevinChen讲师达人认证 悬赏达人认证 SpreadJS 开发认证
论坛元老   /  发表于:2020-12-28 18:16:19
2#
您好,注意到您之前提过类似的问题,参考帖子:
https://gcdn.grapecity.com.cn/showtopic-84129-1-1.html

如果是键盘事件的问题,可以参考这篇示例:
https://www.grapecity.com/wijmo/demos/Grid/Events/Keyboard/purejs
回复 使用道具 举报
醉汀雨笙
金牌服务用户   /  发表于:2020-12-29 08:54:19
3#
這個是在編輯中,或者編輯結束後發生的跳轉,我想要的是不發生編輯,直接跳轉,請問寫在哪個事件裡面?
回复 使用道具 举报
醉汀雨笙
金牌服务用户   /  发表于:2020-12-30 16:31:44
5#
逻辑已实现,请结帖。
谢谢。~~
回复 使用道具 举报
Richard.Ma讲师达人认证 悬赏达人认证 SpreadJS 开发认证
超级版主   /  发表于:2020-12-30 16:52:17
6#
好的
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部