如何把下拉框中的全部放在最上边

全部.PNG

FineReport yzmRnWjP2103775 发布于 2022-7-22 09:05
1min目标场景问卷 立即参与
回答问题
悬赏:3 F币 + 添加悬赏
提示:增加悬赏、完善问题、追问等操作,可使您的问题被置顶,并向所有关注者发送通知
共3回答
最佳回答
0
snrtuemcLv8专家互助
发布于2022-7-22 09:07

参考

选择下拉框,"不选"放第一位,添加一个初始化事件,写一下js语句。

var self = this;  

self.options.name4Empty = "不选"  ;//默认为不选 可以自定义修改

$('input',this.element).click(function(){  

    if(self.$view.css('display')=='none'){  

        self.onTriggerClick();  

    }  

}); 

//全部选择放在第一位

this.addData2View = function(c){

var e = this.editComp.val();

            var b = -1;

            if (this.$view) {

                this.emptyContent = $("<div/>");

                //默认的空添加到第一个位置

            this.initContent(this.emptyContent, this.options.name4Empty, 0);

                this.$view.append(this.emptyContent);

                 var l = document.createDocumentFragment();

                 var g = this.options.data.getLength();

               

                for (var d = g - c.length; d < g; d++) {

                    var k = d + c.length - g;

                    var h = $("<div/>");

                    l.appendChild(h[0]);

                    var f = c[k].getShowValue();

                    this.initContent(h, f, d+1);

                    if (b < 0 && f == e) {

                        b = k

                    }

                }

                this.$view[0].appendChild(l);

               

                FR.HtmlLoader.loadingMoreData({

                    el: this.$view

                });

                this._setSelectedIndex(b);

                this.fixWidth()

 }

}

this.initContent= function(b, e, d) {

            if (e == null) {

                e = ""

            }

            var c = this;

            b.height(this.options.sonHeight).attr("title", e).text(e).addClass(d > -1 ? "fr-combo-list-item" : "fr-combo-list-item fr-combo-list-item-noselect").hover(function(f) {

                c.setFocusWithIndex(d);

                setTimeout(function(h) {

                    if (!h) {

                        return

                    }

                    var g = a(h.target);

                    if (c.$view[0].style.display != "none" && g.isChildAndSelfOf(a(this).parent().children())) {

                        a(this).removeClass("fr-combo-selected")

                    }

                }, 10)

            }).click(function(f) {

                c.inList = true;

                c.fireEvent(FR.Events.CLICK);

                c._setSelectedIndex(d);//修改事件为选中当前的index

                c._onEnterPressed()

            })

        }

        this._selectWithoutTriggerEvent= function() {

            if (this.selectedIndex!=0) {

            //如果不是第一个显示值

                this.setText(this._getSelectedItem().text());

                this.inList = true

            } else {

            //否者显示空

                this.clearText();

                this.searchText = "";

                this.options.need2BuildList = true

            }

            this.checkValid();

            this.collapse()

        }

最佳回答
0
好好生活好好学习Lv7资深互助
发布于2022-7-22 09:25

有个简单的办法,就是在参数数据集最上面拼接一个全部‘然后参数判断全部参数不生效就好了

最佳回答
0
就TM你叫夏洛啊Lv6中级互助
发布于2022-7-22 09:30

union all 一个‘全部’的sql,where 后面不过滤,排序(mysql自定义排序函数:field(字段,'全部',字段))自定义将‘全部’排在在最上面

  • 4关注人数
  • 340浏览人数
  • 最后回答于:2022-7-22 09:30
    请选择关闭问题的原因
    确定 取消
    返回顶部