2013-10-22 2 views
0

다음 코드가 있습니다 (아래 참조). 문제는 열 조건 1의 값이 사용 설명서에 here을 같이 당신은 당신의 자신의 포맷터를 작성해야합니다 0데이터 테이블 내에서 Yahoo 위젯의 조건부 표시

var response = { 
    "id": 1, 
    "items": [ 
     {"condition1": 1, "quantity_value1":"value1"}, 
     {"condition1": 1, "quantity_value1":"value2"}, 
     {"condition1": 0, "quantity_value1":"value3"}, 
     {"condition1": 1, "quantity_value1":"value4"}, 
     {"condition1": 0, "quantity_value1":"value5"}    
    ] 
}; 

var bpColumns = [ 
    {label:'header1', children:[ 
    { 
     key:"condition1" 
    }, 
    { 
     key:"quantity_value1", 
     formatter:YAHOO.widget.DataTable.formatTextbox 
    }]} 
]; 
YAHOO.example.Data = response; 
this.bpDataSource = new YAHOO.util.DataSource(YAHOO.example.Data); 
this.bpDataSource.responseType = YAHOO.util.DataSource.TYPE_JSON; 
this.bpDataSource.responseSchema = { 
    resultsList: "items", 
    fields: ["condition1","quantity_value1"] 
}; 
this.standardSelectDataTable = new YAHOO.widget.ScrollingDataTable("mydiv", 
    bpColumns, this.bpDataSource, {height:"15em"}); 
+0

뭔가 http://jsfiddle.net/sjxSj/2/ 만에 YUI 2.9 –

답변

0

이 작동 :

이 같은
  var response = { 
       "id": 1, 
       "items": [ 
        {"condition1": 1, "quantity_value1":"value1"}, 
        {"condition1": 1, "quantity_value1":"value2"}, 
        {"condition1": 0, "quantity_value1":"value3"}, 
        {"condition1": 1, "quantity_value1":"value4"}, 
        {"condition1": 0, "quantity_value1":"value5"}    
       ] 
      }; 
      var bpColumns = [ 
       {label:'header1', children:[ 
         { 
          key:"condition1" 
         }, 
         { 
          key:"quantity_value1", 
          formatter:"formatTextbox" 
         }]} 
      ]; 
      var vrecord = null; 
      YAHOO.example.Data = response; 
      this.formatTextbox = function(el, oRecord, oColumn, oData, oDataTable) { 
       if (oRecord.getData("condition1") === 1){ 
        var value = (YAHOO.lang.isValue(oData)) ? YAHOO.lang.escapeHTML(oData.toString()) : ""; 
        var input = document.createElement("input"); 
        input.type = "text"; 
        input.value = value; 
        input.onchange = function() 
        { 
         vrecord.setData("quantity_value1",this.value); 
         console.log(vrecord); 
        }; 
        el.appendChild(input); 
       } 
      }; 
      // Add the custom formatter to the shortcuts 
      YAHOO.widget.DataTable.Formatter.formatTextbox = this.formatTextbox; 
      this.bpDataSource = new YAHOO.util.DataSource(YAHOO.example.Data); 
      this.bpDataSource.responseType = YAHOO.util.DataSource.TYPE_JSON; 
      this.bpDataSource.responseSchema = { 
       resultsList: "items", 
       fields: ["condition1","quantity_value1"] 
      }; 
      this.standardSelectDataTable = new YAHOO.widget.ScrollingDataTable("mydiv", 
      bpColumns, this.bpDataSource, {height:"15em"}); 
      this.standardSelectDataTable.subscribe("rowClickEvent", this.standardSelectDataTable.onEventSelectRow); 
      this.standardSelectDataTable.subscribe("rowClickEvent", function(event, target) { 
       var selectedRows = this.getSelectedRows(); 
       vrecord = this.getRecord(selectedRows[0]); 
      }); 
1

때마다 열 quantity_value1에 대한 포맷터 텍스트 상자를 숨기는 방법입니다. 예 : here이 있습니다. 내장 된 방법을 구성 할 방법은 없지만 버전의 기초로 사용할 수 있습니다. source에서 formatTextbox를 검색하십시오.

관련 문제