2014-05-08 140 views
0

我想使用jquery隐藏下拉列表选择中的iggrid列。 我试过以下,但没有工作。在下拉列表中隐藏iggrid列

var hideTheColumn = $("#cntStatusID").val(); 

$("#lifeInsuranceGrid").delegate("iggridhidingcolumnhiding", function (evt, ui) { 
    if (hideTheColumn == 3) { 
     $("#lifeInsuranceGrid").igGridHiding("showColumn", columnsGrid); 
    } else { 
     $("#lifeInsuranceGrid").igGridHiding("hideColumn", columnsGrid); 

    }  
}); 

和我的格子的定义是:

... 
columns: [{ 
     headerText: headerTextValues[0], 
     key: "insuranceID", 
     hidden: true 
    }, { 
     headerText: headerTextValues[1], 
     key: "amount", 
     width: 175, 
     template: "<a href='Home/ManageLifeInsuranceEditor?liId=${insuranceID}&command=edit' class='editLifeDialog'>${amount}</a>" 
    }, { 
     headerText: headerTextValues[2], 
     key: "Benefname", 
     width: 200, 
     template: "<a href='Home/ManageLifeInsuranceEditor?liId=${insuranceID}&command=edit' class='editLifeDialog'>${Benefname}</a>" 
    }, { 
     headerText: headerTextValues[3], 
     key: "Altername", 
     width: 150, 
     template: "<a href='Home/ManageLifeInsuranceEditor?liId=${insuranceID}&command=edit' class='editLifeDialog'>${Altername}</a>" 
    }, { 
     headerText: headerTextValues[4], 
     key: "willMakerTypeDesc", 
     hidden: true, 
     width: 150, 
     template: "<a href='Home/ManageLifeInsuranceEditor?liId=${insuranceID}&command=edit' class='editLifeDialog'>${willMakerTypeDesc}</a>" 
    }, 
], 

回答

0

很难知道正在显示哪部分的代码,但尝试包装你的JavaScript如下:

<script> 
    $(function() { 
     var hideTheColumn = $("#cntStatusID").val(); 

     $("#lifeInsuranceGrid").delegate("iggridhidingcolumnhiding", function (evt, ui) { 
      if (hideTheColumn == 3) { 
      $("#lifeInsuranceGrid").igGridHiding("showColumn", columnsGrid); 
      } else { 
      $("#lifeInsuranceGrid").igGridHiding("hideColumn", columnsGrid); 
      }  
     }); 
    }); 
</script> 
+0

确定。谢谢 。 – Soussou