2、jeecg 筆記之 t:dictSelect 或 t:dgCol 自定義字典
阿新 • • 發佈:2018-10-31
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 如上邊那段了。
3、最後
這種實現方式是比較。。那啥的。。不喜勿噴,歡迎補充。
部落格地址:http://www.cnblogs.com/niceyoo