因为Portal的列表筛选,只有三种样式,文本框、单选和下拉框,如果要用到其他的筛选那就不能配置它了,所以我们可以使用它的Fetch Xml的筛选,来达到我们想要的效果,例如做一个日期选择框,效果图:
做到这个要先在list菜单中添加xml筛选:
<filter type="or" adx:uiinputtype="dynamic" adx:uiname="[逻辑名]"> <condition value="" attribute="[逻辑名]" operator="on-or-after" adx:uiinputtype="dynamic" /> </filter> <filter type="or" adx:uiinputtype="dynamic" adx:uiname="[逻辑名]"> <condition value="" attribute="[逻辑名]" operator="on-or-before" adx:uiinputtype="dynamic" /> </filter>
增加 adx:uiinputtype="dynamic"属性,然后在listjs自定义代码中写入
$(document).ready(function () { //更改“checkbox”控件的类型text $('[name="0"]').prop('type', 'text'); //给他加上id $('[name="0"]').prop('id', 'bk_fld_shipDateAfter'); $('[name="0"]').hide(); //先设置空值 $("#bk_fld_shipDateAfter").val(""); $("input[type=checkbox][name=1]").prop('id', 'bk_fld_shipDateBefore'); $("input[type=checkbox][name=1]").hide(); $("input[type=checkbox][name=1]").prop('type', 'text'); $("#bk_fld_shipDateBefore").val(""); // 隐藏前面几个筛选条件, $("ul#entitylist-filters>li").css("display", "none");
$("ul#entitylist-filters").append(`<li class='entitylist-filter-option-group'> <label data-filter-id='3' class='entitylist-filter-option-group-label h4'>开始时间~结束时间</label> <div id="app"> <el-date-picker v-model='value1' type='daterange' range-separator="-" start-placeholder="开始时间" end-placeholder="结束时间" value-format="yyyy-MM-dd" @change="daterangeClick"> </el-date-picker></div></li>`);const vue = new Vue({ el: '#app', data: function () { return { value1: [], } }, methods: { daterangeClick() { if (this.value1) { $("#bk_fld_shipDateAfter").val(this.value1[0]); $("#bk_fld_shipDateBefore").val(this.value1[1]); } else { $("#bk_fld_shipDateAfter").val(""); $("#bk_fld_shipDateBefore").val(""); } } } });
$("div[class='pull-right']").ready(function () {
// 获取这个div所有按钮html,在页面上有两个,但只会有一个有按钮 var buttonDiv = $("div[class='pull-right']");
for (var i = 0; i < buttonDiv.length; i++) { if (buttonDiv[i].innerHTML != "undefined" && buttonDiv[i].innerHTML != "") { // 添加到查询条件的ul里面 $("ul#entitylist-filters").append("<li class='entitylist-filter-option-group'><label class='entitylist-filter-option-group-label h4' style='height:18px'></label>" + buttonDiv[i].innerHTML + "</li>"); }
}
// 移除原来的按钮 var buttonList = $("div[class='pull-right'] > button");
for (var i = 0; i < buttonList.length; i++) { buttonList[i].remove(); }
});
}); 标签:buttonDiv,name,Power,App,bk,val,筛选,fld,自定义 From: https://www.cnblogs.com/ctwpx/p/16617224.html