Select 无法在slickgrid中使用选择下拉插件

Select 无法在slickgrid中使用选择下拉插件,select,drop-down-menu,slickgrid,Select,Drop Down Menu,Slickgrid,我需要在slickgrid的标题中添加一个下拉列表。正常选择下拉菜单工作正常。我需要使用一个下拉插件,以给它适当的外观和感觉。每当我这样做时,下拉部分就会隐藏在标题中 感谢您的帮助 JSFIDLE的链接如下: var网格; var数据视图; var buttonFormat=函数(行、单元格、值、列定义、数据上下文){ 返回“”; } 变量列=[ {id:“title”,name:“title”,field:“title”}, {id:“术语”,name:“术语”,field:“术语”},

我需要在slickgrid的标题中添加一个下拉列表。正常选择下拉菜单工作正常。我需要使用一个下拉插件,以给它适当的外观和感觉。每当我这样做时,下拉部分就会隐藏在标题中

感谢您的帮助

JSFIDLE的链接如下:


var网格;
var数据视图;
var buttonFormat=函数(行、单元格、值、列定义、数据上下文){
返回“”;
}
变量列=[
{id:“title”,name:“title”,field:“title”},
{id:“术语”,name:“术语”,field:“术语”},
{id:“%”,名称:“%Complete”,字段:“percentComplete”},
{id:“细节”,name:“细节”,field:“细节”,格式化程序:buttonFormat}
];
变量选项={
行高:25,
可编辑:false,
enableAddRow:false,
enableCellNavigation:true,
forcefit列:false,
头灯:100,
多列排序:正确,
是的,
明确化:正确
};
$(函数(){
var数据=[];
对于(变量i=0;i<30;i++){
var days=Math.round(Math.random()*10);
数据[i]={
id:我,
标题:“任务”+i,
期限:天+“天”,
完成百分比:Math.round(Math.random()*100),
描述:“我们正在努力工作”+天+“天!”,
详细信息:空,
toString:function(){
var str=“”;
str+=“Title:”+this.Title+“
”; str+=“Term:”+this.Term+“
”; str+=“Comp:”+this.percentComplete+“
”; str+=“”+this.description+“”; 返回str; } }; } dataView=new Slick.Data.dataView(); dataView.beginUpdate(); dataView.setItems(数据); endUpdate(); grid=new Slick.grid(“#myGrid”、数据视图、列、选项); grid.onClick.subscribe(函数(e,args){ if($(e.target).hasClass(“btn”)){ var item=dataView.getItem(args.row); openDialog(项目); } e、 停止即时复制(); }); grid.onHeaderRowCellRendered.subscribe(函数(e,args){ $(args.node).empty(); if(args.column.id==“详细信息”){ $(“AllActivationDeactionUpload”) .data(“columnId”,args.column.id) .val(“”) .appendTo(参数节点); } }); grid.init(); }); var openDialog=函数(行){ var dom=“”+row.toString()+”; $(dom.dialog(); }; $('select')。每个(函数(){ //缓存选项的数量 变量$this=$(this), numberOfOptions=$(this).children('option').length; //隐藏选择元素 $this.addClass('s-hidden'); //将select元素包装在div中 $this.wrap(“”); //在隐藏的select元素的顶部插入一个样式化的div $this.after(“”); //缓存样式化的div var$styledSelect=$this.next('div.styledSelect'); //在样式化的div中显示第一个select选项 $styledSelect.text($this.children('option').eq(0.text()); //在样式化div之后插入无序列表,并缓存该列表 var$list=$(“
    ”{ “类”:“选项” }).insertAfter($styledSelect); //为每个选择选项在无序列表中插入一个列表项 对于(var i=0;i”{ text:$this.children('option').eq(i).text(), rel:$this.children('option').eq(i).val() }).附件($清单); } //缓存列表项 var$listItems=$list.children('li'); //单击样式化的div时显示无序列表(如果再次单击该div,也会将其隐藏) $styledSelect.单击(函数(e){ e、 停止传播(); $('div.styledSelect.active')。每个(函数(){ $(this.removeClass('active').next('ul.options').hide(); }); $(this.toggleClass('active').next('ul.options').toggle(); }); //单击列表项时隐藏无序列表,并更新样式化div以显示所选列表项 //更新选择元素,使其具有等效选项的值 $listItems。单击(函数(e){ e、 停止传播(); $styledSelect.text($(this.text()).removeClass('active'); $this.val($(this.attr('rel')); $list.hide(); /*警报($this.val());取消对此的注释以进行演示*/ }); //在无序列表外单击时隐藏无序列表 $(文档)。单击(函数(){ $styledSelect.removeClass('active'); $list.hide(); }); }); 身体{ 字体大小:10px; } s-隐藏{ 可见性:隐藏; 右边填充:10px; } .选择{ 光标:指针; 显示:内联块; 位置:相对位置; 字体:普通11px/22px Arial,无衬线; 颜色:黑色; 边框:1px实心#ccc; } .styledSelect{ 位置:绝对位置; 排名:0; 右:0; 底部:0; 左:0; 背景色:白色; 填充:0 10px; 字体大小:粗体; } .styledSelect:after{ 内容:“; 宽度:0; 身高:0; 边框:5px实心透明; 边框颜色:黑色透明; 位置:绝对位置; 顶部:9px; 右:6px; } .styledSelect:active、.styledSelect.active{ 背景色:#eee; } .选项{ 显示:无; 位置:绝对位置; 最高:100%; 右:0; 左:0; z指数:999; 利润率:0; 填充:0; 列表样式:无; 边框:1px实心#ccc; 背景色:白色; -webkit盒阴影:0 1px2pRGBA(0,0,0,0.2); -moz盒阴影:0 1px2pRGBA(0,0,0,0.2); 盒影:0 1px2pRGBA(0,0,0,0.2); } 李先生{ 填充:0 6px; 利润率:0; 填充:0 10px; } .选项李:悬停{ 背景-c
    <div id="myGrid" style="width: 600px; height: 500px;"></div>
    
    
    var grid;
    var dataView;
    
    var buttonFormat = function (row, cell, value, columnDef, dataContext) {
        return "";    
    }
    
    var columns = [
        {id: "title", name: "Title", field: "title"},
        {id: "term", name: "Term", field: "term"},
        {id: "%", name: "% Complete", field: "percentComplete"},
        {id: "detail", name: "Detail", field: "detail",formatter: buttonFormat}
    ];
    
    var options = {
              rowHeight: 25,
              editable: false,
              enableAddRow: false,
              enableCellNavigation: true,
              forceFitColumns: false,
          headerrowheight:100,
              multiColumnSort: true,
              showHeaderRow: true,
          explicitInitialization: true
            };
    
    $(function () {
        var data = [];
        for (var i = 0; i < 30; i++) {
            var days = Math.round(Math.random() * 10);
            data[i] = {
                id: i ,
                title: "Task " + i,
                term: days + " days",
                percentComplete: Math.round(Math.random() * 100),
                description: "We are working hard " + days + " days!",
                detail: null,
                toString:function(){
                    var str = "";
                    str += "Title:" + this.title + "<br/>";
                    str += "Term:" + this.term + "<br/>";
                    str += "Comp:" + this.percentComplete + "<br/>";
                    str += "<b>" + this.description + "</b>";
                    return str;
                }
            };
        }
    
        dataView = new Slick.Data.DataView();    
        dataView.beginUpdate();
        dataView.setItems(data);
        dataView.endUpdate();
    
        grid = new Slick.Grid("#myGrid", dataView, columns, options);
    
        grid.onClick.subscribe(function (e, args) {
            if ($(e.target).hasClass("btn")) {
                var item = dataView.getItem(args.row);
                openDialog(item);
            }
            e.stopImmediatePropagation();
        });
    
        grid.onHeaderRowCellRendered.subscribe(function(e, args) {
                    $(args.node).empty();
                        if(args.column.id=="detail"){
    
                        $("<select style='width: 70px;'><option value=''>All</option><option value='Activation'>Activation</option><option value='Deactivation'>Deactivation</option><option value='Upload'>Upload</option></select>")
                       .data("columnId", args.column.id)
                       .val("")
                       .appendTo(args.node); 
                 }
    
    
                });
          grid.init();
    
    });
    
    var openDialog = function(row){
        var dom = "<div>" + row.toString() + "</div>";
        $(dom).dialog();
    };
    $('select').each(function () {
    
        // Cache the number of options
        var $this = $(this),
            numberOfOptions = $(this).children('option').length;
    
        // Hides the select element
        $this.addClass('s-hidden');
    
        // Wrap the select element in a div
        $this.wrap('<div class="select"></div>');
    
        // Insert a styled div to sit over the top of the hidden select element
        $this.after('<div class="styledSelect"></div>');
    
        // Cache the styled div
        var $styledSelect = $this.next('div.styledSelect');
    
        // Show the first select option in the styled div
        $styledSelect.text($this.children('option').eq(0).text());
    
        // Insert an unordered list after the styled div and also cache the list
        var $list = $('<ul />', {
            'class': 'options'
        }).insertAfter($styledSelect);
    
        // Insert a list item into the unordered list for each select option
        for (var i = 0; i < numberOfOptions; i++) {
            $('<li />', {
                text: $this.children('option').eq(i).text(),
                rel: $this.children('option').eq(i).val()
            }).appendTo($list);
        }
    
        // Cache the list items
        var $listItems = $list.children('li');
    
        // Show the unordered list when the styled div is clicked (also hides it if the div is clicked again)
        $styledSelect.click(function (e) {
            e.stopPropagation();
            $('div.styledSelect.active').each(function () {
                $(this).removeClass('active').next('ul.options').hide();
            });
            $(this).toggleClass('active').next('ul.options').toggle();
        });
    
        // Hides the unordered list when a list item is clicked and updates the styled div to show the selected list item
        // Updates the select element to have the value of the equivalent option
        $listItems.click(function (e) {
            e.stopPropagation();
            $styledSelect.text($(this).text()).removeClass('active');
            $this.val($(this).attr('rel'));
            $list.hide();
            /* alert($this.val()); Uncomment this for demonstration! */
        });
    
        // Hides the unordered list when clicking outside of it
        $(document).click(function () {
            $styledSelect.removeClass('active');
            $list.hide();
        });
    
    });
    
    
    body{
        font-size:10px;    
    }
    .s-hidden {
        visibility:hidden;
        padding-right:10px;
    }
    .select {
        cursor:pointer;
        display:inline-block;
        position:relative;
        font:normal 11px/22px Arial, Sans-Serif;
        color:black;
        border:1px solid #ccc;
    }
    .styledSelect {
        position:absolute;
        top:0;
        right:0;
        bottom:0;
        left:0;
        background-color:white;
        padding:0 10px;
        font-weight:bold;
    }
    .styledSelect:after {
        content:"";
        width:0;
        height:0;
        border:5px solid transparent;
        border-color:black transparent transparent transparent;
        position:absolute;
        top:9px;
        right:6px;
    }
    .styledSelect:active, .styledSelect.active {
        background-color:#eee;
    }
    .options {
        display:none;
        position:absolute;
        top:100%;
        right:0;
        left:0;
        z-index:999;
        margin:0 0;
        padding:0 0;
        list-style:none;
        border:1px solid #ccc;
        background-color:white;
        -webkit-box-shadow:0 1px 2px rgba(0, 0, 0, 0.2);
        -moz-box-shadow:0 1px 2px rgba(0, 0, 0, 0.2);
        box-shadow:0 1px 2px rgba(0, 0, 0, 0.2);
    }
    .options li {
        padding:0 6px;
        margin:0 0;
        padding:0 10px;
    }
    .options li:hover {
        background-color:#39f;
        color:white;
    }
    .slick-headerrow-columns {
        height: 100px !important;
    }
    
    .slick-headerrow  {
        overflow: unset !important;
    }
    
    .slick-headerrow-column, .slick-headerrow-columns {
        overflow: unset;
    }