• 2、jeecg 笔记之 t:dictSelect 或 t:dgCol 自定义字典


     1、需求

    先说一下需求场景吧,我们知道 jeecg 中提供了下拉,其中包含两种使用场景;

    一种是直接通过 t:dictSelect 使用,再就是 t:dgCol  用于表头的列表工具条标签;

    总之就是这个样子

    需求来了,我们想要下拉的数据有个排序,比如原来没有排序的

    再来看一下数据字典表中的数据如下:

    然后,我们希望通过 类型编码做一个 倒序的排序,最终的效果如下:

    2、解决过程

    首先通过查找资料了解到,下拉中有个 dictionary 属性,可以通过自定义字典实现效果,格式:表名,编码,显示文本;

    但是想使用自定义字典需要结合 dictCondition(自定义字典表的显示文本-字典查询条件) 属性;

    在 DataGridTag 类 559 行找到了,找到了字典查询条件 dictCondition 的使用

    图片展示已经很明确了,就是一个 sql 的拼装,我们只需要能把 sql 写出来就完事了,如下图

    SELECT a.typecode,a.typename FROM t_s_type a 
    
    ,t_s_typegroup b WHERE a.typegroupid = b.id  
    
    AND b.typegroupcode = 'mwo_work_order_status' ORDER BY typecode DESC 

    因为界面要用到编码以及显示文本,所以只需要 typecode、typename作为显示项。

    我们再来看一下自定义字典的格式 【表名,编码,显示文本】

    <t:dgCol title="啦啦啦"  field="xxx"  queryMode="single" query="true" 
    dictionary="t_s_type,a.typecode,a.typename"
    dictCondition="a ,t_s_typegroup b WHERE a.typegroupid = b.id  
    AND b.typegroupcode = 'mwo_work_order_status' ORDER BY typecode DESC ">
    </t:dgCol>

    dictionary="t_s_type,a.typecode,a.typename"  >>> 表名,编码,显示文本

    dictCondition="a ,t_s_typegroup b WHERE a.typegroupid = b.id  AND b.typegroupcode = 'mwo_work_order_status' ORDER BY typecode DESC "

    最终拼接起来的 sql 如上边那段了。

    再给一个参考:

    <t:dictSelect field="mwoApplyDelayProcess" type="radio"
        dictTable="t_s_type a ,t_s_typegroup b"
        dictField="a.typecode,a.typename,a.typecode"
        dictCondition="WHERE a.typegroupid = b.id  AND  b.typegroupcode = 'mwo_apply_delay_process' AND  a.`typecode` IN (2,3)"
        dictText="typename"
        defaultVal="${myyWorkOrderPage.mwoApplyDelayProcess}"  hasLabel="false"  title="申请延期状态"  datatype="*">
    </t:dictSelect>

    3、最后

    这种实现方式是比较。。那啥的。。不喜勿喷,欢迎补充。

    博客地址:http://www.cnblogs.com/niceyoo

      18年专科毕业后,期间一度迷茫,最近我创建了一个公众号用来记录自己的成长

  • 相关阅读:
    python习题-用交集方式产生随机密码
    python习题-产生8位随机密码要包含大小写及数字
    python习题-替换敏感词
    python习题-注册用户程序
    Python习题-登录
    Python习题-统计日志中访问次数超过限制的IP
    PyCharm配置过程记录
    jmeter 多压力机并发测试过程
    Jmete基础使用
    Linux 中直接 I/O 机制的介绍
  • 原文地址:https://www.cnblogs.com/niceyoo/p/9827668.html
Copyright © 2020-2023  润新知