Скрыть столбец iggrid при раскрывающемся списке

Я хотел бы скрыть столбец iggrid при выборе выпадающего списка с помощью Jquery. Я попробовал следующее, но не сработало.

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>"
    },
],

1 ответ

Трудно понять, какая часть вашего кода показывается, но попробуйте заключить в 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>
Другие вопросы по тегам