0

我在应用程序中使用 jqgrid 和自定义操作格式化程序。我在loadComplete. 我想根据 Col1 的值禁用/启用此操作,例如,如果 col1 的值为 true,则操作设置为 true 时可见.... 怎么做?

 grid.jqGrid({
    url: 'jqGridHandler.ashx',
    datatype: 'json',
    colNames: ['Action','Col1','col2'],
    colModel: [
        {
            name: 'act',
            width: ($.browser.webkit ? 25 : 25),
            align: 'center',
            sortable: false,
            formatter: 'actions',
            formatoptions: {
                keys: true,
                delbutton: false,
                editbutton: false
            }
        },
        { name: 'Col1', width: 100, sortable: true, hidden: true },
        { name: 'col2', width: 100, sortable: true, hidden: true }
    ],
    rowNum: 20,
    rowList: [5, 10, 20],
    recordpos: "left",
    toppager: true,
    viewrecords: true,
    sortorder: "desc",
    scrollOffset: 1,
    jsonReader:
    {
        repeatitems: false,
    },
    gridview: true,
    loadComplete: function () {
        var iCol = getColumnIndexByName(grid, 'act');
        $(this).find(">tbody>tr.jqgrow>td:nth-child(" + (iCol + 1) + ")")
            .each(function () {
                $("<div>", {
                    title: "MyAction",
                    mouseover: function () {
                        $(this).addClass('ui-state-hover');
                    },
                    mouseout: function () {
                        $(this).removeClass('ui-state-hover');
                    },
                    click: function (e) {
                        alert("'Custom' button is clicked in the rowis=" +
                            $(e.target).closest("tr.jqgrow").attr("id") + " !");
                    }
                }
                ).css({ "margin-right": "5px", "float": "left", "cursor": "pointer" })
                    .addClass("ui-pg-div ui-inline-custom")
                    .append('<span class="ui-icon icon-archive"></span>')
                    .prependTo($(this).children("div"));
            });
    },
4

1 回答 1

0

我会尝试过滤集合并只做正确的单元格

var iCol = getColumnIndexByName(grid, 'act');
var iCol1 = getColumnIndexByName(grid, 'Col1'); 
$(this).find(">tbody>tr.jqgrow>td:nth-child(" + (iCol + 1) + ")")
//  .each(function () {

  .filter(function (index) {
      true==$(this).find(">tbody>tr.jqgrow>td:nth-child(" + (iCol1 + 1) + ")").val();
}) {
于 2013-06-10T07:46:31.640 回答