zoukankan      html  css  js  c++  java
  • eas之编辑表单元格

    --指定表列行单元不可编辑

    // 锁定表格、行、列、单元

    table.getStyleAttributes().getProtection().setLocked(true);

    row.getStyleAttributes().getProtection().setLocked(true);

    col.getStyleAttributes().getProtection().setLocked(true);

    cell.getStyleAttributes().getProtection().setLocked(true);

     

    表头默认是不可编辑的,必须先把Lock关闭。其他操作就和编辑表体一样。

    table.getHeadRow().getStyleAttributes().getProtection().setLocked(false);

     

    判断指定或者单元格是否允许输入空格,不允许则自动去掉

    table.getEditManager().setAllowBlankCharacter (boolean isAllow);

    table.getEditManager().isAllowBlankCharacter (boolean isAllow);

     

    KDTable的编辑器支持类型绑定和手动绑定两种。

    类型绑定即无须指定编辑器,KDTable将根据单元格的值类型,自动绑定到相应的编辑器上。目前内置支持的绑定有(String,JTextField)、(Boolean,JCheckBox)、(Date,KDDatePicker)、(其他类型,JTextField)。数据类型到编辑器的绑定是可扩充的。

    手动绑定即用户自己创建编辑器,并绑定到行、列或单元对象上。当编辑器绑定到行、列上时,将应用到行、列上的所有单元格。

    手动绑定优先于类型绑定。

    // 扩充类型绑定,指定表格中的整型都用指定编辑器编辑

    table.putDefaultEditor(Integer.class, yourIntegerEditor);

    // 下面的例子演示手动绑定JComboBox类型的编辑器到第三列上

    // 创建一个JComboBox JComboBox c = new JComboBox(new String [] {"", "hhh1", "hhh2" , "hhh3"});

    // KDTable要求的编辑器必须实现KDTCellEditor接口

    // KDTDefaultCellEditor是一个辅助类,可以帮助你将JComboBox转化为KDTable支持的编辑器。KDTDefaultCellEditor cellEditor = new KDTDefaultCellEditor(c);

    // 将编辑器绑定到列对象上,此处同样可绑定到行或单元对象table.getColumn(3).setEditor(cellEditor);

     

    // 启动编辑,rowIndex和colIndex分别为编辑单元的行列索引。

    table.getEditManager().editCellAt(rowIndex, colIndex);

    // 结束编辑

    table.getEditManager().stopEditing();

    // 取消编辑

    table.getEditManager().cancelEditing();

    承接钉钉定制;网站服务定制; 联系qq:1655119603
  • 相关阅读:
    tomcat部署项目时 报错Tomcat version 7.0 only supports J2EE 1.2, 1.3, 1.4, and Java EE 5 and 6 Web modules
    异常:Caused by: java.lang.NoClassDefFoundError: org/springframework/web/context/WebApplicationContext
    java安全管理器SecurityManager介绍
    Mybatis框架基础支持层——反射工具箱之Reflector&ReflectorFactory(3)
    Mybatis框架基础支持层——解析器模块(2)
    Mybatis框架可视化(1)
    JDK动态代理简单使用(2)
    代理(1)
    动态代理源码分析(3)
    springboot(十七)-使用Docker部署springboot项目
  • 原文地址:https://www.cnblogs.com/luojiabao/p/10963727.html
Copyright © 2011-2022 走看看