thomasJang / axisj

javascript UI library
http://axisj.com/
GNU Lesser General Public License v2.1
310 stars 86 forks source link

그리드 colGroup에서 선언한 key에 해당하는 컬럼자체를 안보이거나 없애고 싶은데요... #877

Open lspclass opened 8 years ago

lspclass commented 8 years ago

{ key:"cnt",label:"댓글여부",width:"100",align:"center", colHeadTool : false }, 이부분을 cnt가 1이냐 0이냐에따라서 보이고 안보이고를 구현하고 싶은데 잘 모르겠습니다. 알려주시면 감사하겠습니다. ㅠ.ㅠ 수고하세요

밑에는 소스입니다...

    gridinit : function(){
        this.grid.setConfig({
            targetID : "boardPostInfoListGrid_${boardUniqId}",
                            theme : "AXGrid",
            tabId : tab.getTabId(), 
            autoChangeGridView: {
                mobile:[0,600], grid:[600]
            },
            height:defaultHeight,
            remoteSort: true,
            colHeadTool: false,
            colHeadAlign: "center",
            reserveKeys : { 
                hidden : "postCreateId"
            },
            colGroup : [
                { key:"rowNo", label:"선택", width:50, align:"center", formatter:"radio", sort:false, checked:function(){ return this.item.checked; } },
{ key:"postUniqNo",label:"게시번호",width:"90",align:"center" }, { key:"boardNm",label:"게시판",width:"180",align:"center" }, /c:if /\* { key:"postNo",label:"번호",width:"90",align:"center" }, _/ { key:"postNm",label:"제목",width:"600",align:"left" }, { key:"postCreateNm",label:"작성자",width:"130",align:"center" }, /_ { key:"isUsed",label:"공개여부",width:"90",align:"center",formatter: function() { return this.item.isUsed == '1' ? "공개" : "비공개"; } }, */ { key:"cnt",label:"댓글여부",width:"100",align:"center", colHeadTool : false }, ``` { key:"createDate",label:"작성일",width:140, align:"center",formatter: function() { return new Date(this.item.createDate).format("yyyy-MM-dd HH:mm:ss"); } }, { key:"updateNm",label:"수정자",width:"130",align:"center" }, { key:"updateDate",label:"수정일", width:140, align:"center",formatter: function() { return new Date(this.item.updateDate).format("yyyy-MM-dd HH:mm:ss"); } } ], body : { onclick: function(){ if(this.c == 0) return false; tab.fn_detail("system/board/getBoardPostInfo.html?postUniqNo="+this.item.postUniqNo + "&postCreateId=" + this.item.postCreateId, 600); }, }, page: Object.clone(defaultpage) }); }, ```
thomasJang commented 8 years ago

http://codepen.io/thomasJang/pen/reyNPZ 를 참고해주세요.

var fnObj = {
  pageStart: function(){
    var _this = this;
    $("#grid-remove").click(function(){
      _this.gridView0.removeList(_this.gridView0.getCheckedList());
    });

    var list = [
      {no: 1, string: "AXGrid 첫번째 줄 입니다."},
      {no: 2,string: "AXGrid 두번째 줄 입니다."}
    ];
    this.gridView0.initView(list);    

  }
}

fnObj.gridView0 = {
  target: new AXGrid(), 
  initView: function(list){
   /// 여기에서 colGroup을 변경하면 되겠습니다.
    this.target.setConfig({
      targetID: "AXGridTarget",
      colHeadAlign: "center",
      colGroup: [
        {key: "no", label: "번호", width: "50", align: "center", formatter: "checkbox"},
        {key: "string", label: "String", width: "100", formatter: function(){
          return "<b>12</b>"
        }}
      ],
      body:{
        onclick: function(){
          alert(this.c);
          console.log(this);
        }
      }
    });
    this.setData(list);
  },
  setData: function(list){
    this.target.setList(list);
  },
  getData: function(){
    return this.target.list;
  },
  getCheckedList: function(){
    return this.target.getCheckedList(0);
  },
  removeList: function(list){
    this.target.removeList(list);
  }
}

$(document.body).ready(function(){
  fnObj.pageStart();
});