Создание флажка в Javascript и Dhtmlx

Я пытаюсь создать флажок на основе javascript, но почему-то не могу заставить его работать. Я создал вопрос ранее, но почему-то не смог добавить свой код в комментарии, поэтому создал новый вопрос. Вот что я сделал:

function eXcell_includeDC(cell) {
    if (cell){            // the default pattern, just copy it
        this.cell = cell;
        this.grid = this.cell.parentNode.grid;
    }
    this.getValue = regExpGetValueCell;

    if (this.getValue = 'Y') {
        var myDiv = document.getElementById("includeDC");
        var checkbox = document.createElement("input"); 
        checkbox.setAttribute("type", "checkbox");
        checkbox.setAttribute("name", "dd");
        checkbox.setAttribute("value", "ff");
        checkbox.checked = true; 
        myDiv.appendChild(checkbox); 
        checkbox.checked = true;
    } else {
        var myDiv = document.getElementById("includeDC");
        var checkbox = document.createElement("input"); 
        checkbox.setAttribute("type", "checkbox");
        checkbox.setAttribute("name", "dd");
        checkbox.setAttribute("value", "ff");
        checkbox.checked = true; 
        myDiv.appendChild(checkbox); 
        checkbox.checked = false;
    }
    this.isDisabled = function() { 
        return true; 
    } 
    this.setValue=function(val) {
        // actual data processing may be placed here, for now we just set value as it is
        this.setCValue(val); 
    }
}
eXcell_includeDC.prototype = new eXcell;

person hell_storm2004    schedule 20.06.2016    source источник


Ответы (1)


Вам нужно создать весь свой html-контент, который должен отображаться в вашей ячейке, в функции setValue. Вот упрощенный пример:

function eXcell_includeDC(cell){ //the eXcell name is defined here
    if (cell){                // the default pattern, just copy it
        this.cell = cell;
        this.grid = this.cell.parentNode.grid;
    }
    this.edit = function(){}  //read-only cell doesn't have edit method
    // the cell is read-only, so it's always in the disabled state
    this.isDisabled = function(){ return true; }
    this.setValue=function(val){
        if (val=="Y")
        this.setCValue("<input type='checkbox' checked='checked/>",val);
        else
        this.setCValue("<input type='checkbox'/>",val);
    }
}
eXcell_includeDC.prototype = new eXcell;
person sematik    schedule 21.06.2016
comment
Потрясающий! Это здорово помогло! :) - person hell_storm2004; 21.06.2016