找回密码
 立即注册

QQ登录

只需一步,快速开始

mtkj
金牌服务用户   /  发表于:2020-5-21 14:30  /   查看:3003  /  回复:2
1金币
对于flexgrid编辑某一个单元格时,用光标进行左右移动,当光标移动至最左侧(最右侧)时,需跳至前一个(后一个单元格)

最佳答案

查看完整内容

你好,这个问题没有原生的接口直接实现,但可以通过JSDOM的特性来实现,参考以下代码: 在这里可以看到效果: https://demo.grapecity.com.cn/wijmo/demos/Input/AutoComplete/Overview/purejs 注意需要给html页面上加一个id是btn的按钮

2 个回复

倒序浏览
最佳答案
最佳答案
KevinChen讲师达人认证 悬赏达人认证 SpreadJS 开发认证
论坛元老   /  发表于:2020-5-21 14:30:56
来自 3#
你好,这个问题没有原生的接口直接实现,但可以通过JSDOM的特性来实现,参考以下代码:

  1. import 'bootstrap.css';
  2. import '@grapecity/wijmo.styles/wijmo.css';
  3. import './styles.css';
  4. //
  5. import * as input from '@grapecity/wijmo.input';
  6. import { getData } from './data';
  7. //
  8. document.readyState === 'complete' ? init() : window.onload = init;
  9. //
  10. function init() {
  11.     (function ($, undefined) {
  12.         $.fn.getCursorPosition = function () {
  13.             var el = $(this).get(0);
  14.             var pos = 0;
  15.             if ('selectionStart' in el) {
  16.                 pos = el.selectionStart;
  17.             } else if ('selection' in document) {
  18.                 el.focus();
  19.                 var Sel = document.selection.createRange();
  20.                 var SelLength = document.selection.createRange().text.length;
  21.                 Sel.moveStart('character', -el.value.length);
  22.                 pos = Sel.text.length - SelLength;
  23.             }
  24.             return pos;
  25.         }
  26.     })(jQuery);
  27.     let theCombo = new input.ComboBox('#theCombo', {
  28.         displayMemberPath: 'country',
  29.         itemsSource: getData()
  30.     });
  31.     //
  32.     let theAutoComplete = new input.AutoComplete('#theAutoComplete', {
  33.         displayMemberPath: 'country',
  34.         itemsSource: getData()
  35.     });

  36.     $("#btn").click(function(){
  37.         var host = theAutoComplete.hostElement;
  38.         var input = $(host).find("input");
  39.         console.log(input.getCursorPosition());
  40.     });
  41. }
复制代码


在这里可以看到效果:

https://demo.grapecity.com.cn/wi ... ete/Overview/purejs

注意需要给html页面上加一个id是btn的按钮
回复 使用道具 举报
KevinChen讲师达人认证 悬赏达人认证 SpreadJS 开发认证
论坛元老   /  发表于:2020-5-21 18:08:31
2#
你好,input组件没有原生的光标事件,和获取光标位置的接口,这个问题需要进一步调研。预计明天上午回复您
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部