Slickgrid, column with a drop down select list?

前端 未结 4 1386
滥情空心
滥情空心 2020-12-03 01:20

Hi I was wondering if anyone knows if it\'s possible to define a column in slickgrid as being a drop down select list. If not does anyone with some experience with slickgrid

4条回答
  •  半阙折子戏
    2020-12-03 01:51

    I assume you mean a custom cell editor. Here's a sample select-based boolean cell editor from slick.editors.js. You could easily modify it to work with an arbitrary set of possible values.

    function YesNoSelectCellEditor($container, columnDef, value, dataContext) {
        var $select;
        var defaultValue = value;
        var scope = this;
    
        this.init = function() {
            $select = $("");
    
            if (defaultValue)
                $select.val('yes');
            else
                $select.val('no');
    
            $select.appendTo($container);
    
            $select.focus();
        };
    
    
        this.destroy = function() {
            $select.remove();
        };
    
    
        this.focus = function() {
            $select.focus();
        };
    
        this.setValue = function(value) {
            $select.val(value);
            defaultValue = value;
        };
    
        this.getValue = function() {
            return ($select.val() == 'yes');
        };
    
        this.isValueChanged = function() {
            return ($select.val() != defaultValue);
        };
    
        this.validate = function() {
            return {
                valid: true,
                msg: null
            };
        };
    
        this.init();
    };
    

提交回复
热议问题