JQGrid会自动隐藏单元格中带有false的行

问题描述:

如果其中的单元格具有false值,我试图隐藏一行,到目前为止,我已尝试使用这样的格式化程序:

I'm trying to hide a Row if a cell in it has the false value, so far I've tried using a formatter like this:

$("#list").jqGrid({
            //datatype: 'clientSide',
            colNames: ["Id", "Descrizione", "Data Vendita", "Disabilitato", "PISTA", 
                       "Piano Tariffario", "Data Validità Piano Tariffario", 
                       "PROMO", "Data Validità Promo", "CANONE CLIENTE NETTO MESE", 
                       "Vendibile", "Migrato"],
            colModel: [
                { name: "id"},
                { name: "descrizione", editable: true},
                { name: "dataInizVendita", editable: true, formatter:vendita},                          
                { name: "disabilitato", editable: true},
                { name: "pista", editable: true},
                { name: "pianoTariffario", editable: true},
                { name: "dataInizPiano", editable: true, formatter:piano},              
                { name: "promo", editable: true},
                { name: "dataInizPromo", editable: true, formatter:promo},
                { name: "canoneNetto", editable: true},
                { name: "disponibilita", editable: true, formatter:mostra},
                { name: "migrato", editable: true, width:150, sortable: false, resizable:false, formatter:bottone}          
            ],
            formatter: 'date', 
            formatoptions: { srcformat: 'd/m/Y', newformat: 'd/m/Y'},
            sortname: "id",
            sortorder: "asc"

        })

我关心的格式化程序是大多数,如果disponibilita是假的,它必须隐藏行!

The formatter that I care about is mostra, if disponibilita is false, it must hide the row!

function mostra (cellvalue, options, rowObject)
{               

    if(rowObject.disponibilita == false)
    {               
        $("#"+rowObject.id).hide();
    }
    $("#list").trigger("reloadGrid");
    return rowObject.disponibilita;
}

我也试过使用delRowdata,但它没有删除它,

I've tried using delRowdata too, but it doesn't remove it, and it can see when it's false and when it's not, because the if function works perfectly

它会更好 删除数据, disponibilita 列中的 false 之前数据将由jqGrid处理。如果是数据类型:local应该只修改输入数据,然后使用 data 参数修改输入。如果从服务器加载数据,可以使用 beforeProcessing 回调来修改从服务器返回的数据。

It would be better to delete the data, which have false value in disponibilita column before the data will be processed by jqGrid. In case of datatype: "local" one should just modify the input data and then use data parameter with modifies input. In case of loading the data from the server one can use beforeProcessing callback to modify the data returned from the server.

只有在由于某些其他原因导致无法实现上述情况时,您才能使用以下格式的 rowattr 回调

Only if you can't implement the above scenarios because of some additional reasons, you can use rowattr callback in the following form

rowattr: function (item) { // !rowObject.disponibilita in your case
    if (item.closed) {
        return {style: "display:none;"};
    }
}

参见演示或课堂形式:

rowattr: function (item) {
    if (item.closed) {
        return {"class": "my-hide"};
    }
}

参见另一个演示。您可以看到这两种解决方案都有效,但页面大小不正确。

see another demo. You can see then both of the solutions works, but the page size is not correct.