jeecg自定义按钮使用exp属性不起作用
jeecg自定義按鈕使用exp屬性不起作用
為什么要寫這篇文章?
之前寫過一篇類似的文章 jeecg筆記之自定義顯示按鈕exp屬性,但是有些小伙伴留言參考后不起作用,當(dāng)時(shí)我的 jeecg 版本為3.7.5,最終以版本不同,暫時(shí)擱淺了。
今天,重新回到這個(gè)問題,一起去討伐這個(gè)不起效果的 exp。
前臺參考界面
因?yàn)橹匦吕〉男掳姹?jeecg(3.8),沒有合適的場景演示,那么就參考一下官方的使用案例吧。
Online表單開發(fā)界面(cgFormHeadList.jsp):
主要參考代碼部分:
<t:dgFunOpt?exp="isDbSynch#eq#N"?title="sync.db"?funname="doDbsynch(id,content)"?urlclass="ace_button"??urlfont="fa-database"/><t:dgFunOpt?exp="isDbSynch#eq#Y&&jformType#ne#3"?funname="addbytab(id,content)"?title="form.template"?urlclass="ace_button"?urlStyle="background-color:#5F9EA0"?urlfont="fa-cog"></t:dgFunOpt>
<t:dgFunOpt?exp="isDbSynch#eq#Y&&jformType#ne#3"?funname="addlisttab(tableName,content)"?title="function.test"?urlStyle="background-color:#18a689;"?urlclass="ace_button"??urlfont="fa-gavel"></t:dgFunOpt>
<t:dgFunOpt?exp="isDbSynch#eq#Y&&jformType#ne#3"?funname="popMenuLink(tableName,content)"?title="config.place"?urlStyle="background-color:#1a7bb9;"?urlclass="ace_button"??urlfont="fa-cog"?></t:dgFunOpt>
<t:dgFunOpt?funname="copyOnline(id)"?title="復(fù)制表單"?operationCode="copyOnlineTable"??urlclass="ace_button"??urlfont="fa-copy"></t:dgFunOpt>
<t:dgFunOpt?exp="hasPeizhi#ne#0"?funname="propertyTable(id)"?title="配置表"??urlclass="ace_button"??urlfont="fa-cog"></t:dgFunOpt>
當(dāng)我看到新版本這幾行代碼的時(shí)候,感覺哪里怪怪的,這跟上幾個(gè)版本差不多呀!
信誓旦旦的去比對了一下兩個(gè)文件的差異,如下:
事實(shí)證明,確實(shí)沒有差距,只是新版本寬度樣式稍微變化了一下。
分析一行代碼部分(功能測試按鈕):
<t:dgFunOpt?exp="isDbSynch#eq#Y&&jformType#ne#3"?funname="addlisttab(tableName,content)"?title="function.test"?urlStyle="background-color:#18a689;"?urlclass="ace_button"??urlfont="fa-gavel"></t:dgFunOpt>表達(dá)式:isDbSynch#eq#Y&&jformType#ne#3
- isDbSynch:屬性字段,注意是實(shí)體字段,非數(shù)據(jù)庫表字段列名稱
- eq:條件判斷中的等于,ne 為不等于
- empty:為空判斷,條件為 true 或者 false。
補(bǔ)充
關(guān)于 exp 具體實(shí)現(xiàn)代碼部分,在此就不展開說明了,感興趣的小伙伴可以看一下這個(gè)類 DataGridTag.java 的 2552 行代碼:
String?exp?=?dataGridUrl.getExp();//?判斷顯示表達(dá)式if?(StringUtil.isNotEmpty(exp))?{
????String[]?ShowbyFields?=?exp.split("&&");
????for?(String?ShowbyField?:?ShowbyFields)?{
????????int?beginIndex?=?ShowbyField.indexOf("#");
????????int?endIndex?=?ShowbyField.lastIndexOf("#");
????????String?exptype?=?ShowbyField.substring(beginIndex?+?1,?endIndex);//?表達(dá)式類型
????????String?field?=?ShowbyField.substring(0,?beginIndex);//?判斷顯示依據(jù)字段
????????String[]?values?=?ShowbyField.substring(endIndex?+?1,?ShowbyField.length()).split(",");//?傳入字段值
????????String?value?=?"";
????????for?(int?i?=?0;?i?<?values.length;?i++)?{
????????????value?+=?"'"?+?""?+?values[i]?+?""?+?"'";
????????????if?(i?<?values.length?-?1)?{
????????????????value?+=?",";
????????????}
????????}
????????if?("eq".equals(exptype))?{
????????????sb.append("if($.inArray(rec."?+?field?+?",["?+?value?+?"])>=0){");
????????}
????????if?("ne".equals(exptype))?{
????????????sb.append("if($.inArray(rec."?+?field?+?",["?+?value?+?"])<0){");
????????}
????????if?("empty".equals(exptype)?&&?value.equals("'true'"))?{
????????????sb.append("if(rec."?+?field?+?"==''){");
????????}
????????if?("empty".equals(exptype)?&&?value.equals("'false'"))?{
????????????sb.append("if(rec."?+?field?+?"!=''){");
????????}
????}
}
最后
雖然上方,我通過 3.8 版本重新嘗試了 exp 屬性,但是你仍然存在無法生效的問題的話,歡迎交流~。
文章作者:niceyoo
文章地址:https://www.cnblogs.com/niceyoo/p/10520278.html
如果覺得文章對你有所幫助,右下方點(diǎn)個(gè)推薦~
posted @ 2019-03-12 22:59 niceyoo 閱讀(...) 評論(...) 編輯 收藏
總結(jié)
以上是生活随笔為你收集整理的jeecg自定义按钮使用exp属性不起作用的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 极域九法——小白看得懂的退出极域电子教室
- 下一篇: Windows 虚拟机介绍以及安装系统教