2016-06-20 6 views
1

자바 스크립트 기반의 체크 박스를 만들려고하고 있지만 어떻게 든 작동하게 만들 수는 없습니다. 이전에 질문을 만들었지 만 의견에 코드를 추가 할 수 없으므로 새로운 질문을 던집니다. 이것은 내가 한 일입니다 :자바 스크립트 및 Dhtmlx로 체크 박스 만들기

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; 

답변

2

setValue 함수에서 셀에 표시해야하는 모든 HTML 콘텐츠를 만들어야합니다. 다음은 간단한 예입니다.

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; 
+0

굉장! 이것은 큰 도움이되었습니다! :) –

관련 문제