1

私は次の店を持っています:

var dnrListStore = new Ext.data.ArrayStore({
fields: [
    {name: 'SUBSYS_ART_NR', type: 'int'},
    {name: 'ART_DESC', type: 'string'},
    {name: 'SORTEN_TEXT', type: 'auto'},
    {name: 'VAR', type: 'int'},
    {name: 'GEBI', type: 'int'},
    {name: 'DNR_ID', type: 'int'},
    {name: 'STATUS', type: 'int'},
    {name: 'LEVEL0', type: 'float'},
    {name: 'VALUE0', type: 'float'},
    {name: 'LEVEL1', type: 'float'},
    {name: 'VALUE1', type: 'float'},
    {name: 'LEVEL3', type: 'float'},
    {name: 'VALUE3', type: 'float'}
],
data: dnrList
});

一部の列 ( LEVELX および VALUEX ) はnull、従業員が入力した値が原因である可能性があります。したがって、値を使用できない列を非表示にしたいと思います。checkValue関数は適切に機能し、正しい値を返します。以下を試しましたが、何も起こりません。

var checkValue = function(arg) {
var v = {};
for (var i = 0; i < dnrList.length; i++) {
    v[i] = dnrList[i].data;
}

for (var key in v) {
    if (v[key].hasOwnProperty(arg)) {
        return true
    } else {
        return false
    }
}
}

// on grid columns definition
columns: [
    {text: 'LEVEL 1', dataIndex: 'LEVEL1', hidden: checkValue("LEVEL1")}
]

// or
columns: [
    {text: 'LEVEL 1', dataIndex: 'LEVEL1', hidden: (checkValue("LEVEL1") ? true : false)}
]

私たちがそれをどのように行うか分かりますか?


の方法 この方法では、タスクを達成できますが、実現可能ではありません!

columns:[
   {
       text: 'LEVEL 1', dataIndex: 'LEVEL1',
       renderer: function(val, meta, rec, row, col) {
           if (val == null) {
              Ext.getCmp('summary-grid').headerCt.remove(col);
           } else {
              return rec.get('LEVEL1')
           }
       }
   }
]
4

1 に答える 1

2

あなたのソリューション/アプローチは実現可能ではないと思います.ユーザーがどの値がnullであるかをどのように知る必要があるか. 列 (レベル 1 など) に対して次の応答が得られた場合はどうしますか。

レベル1
------
(null) ----> LEVEL 1 列を非表示に設定します
some-value ----> そして今何?
some-other-value ----> 再度表示を設定しますか?

とにかく、列のすべてのデータが null のときに列を非表示にする場合は、次のようにストアのロード イベントにそのようなロジックを追加できます。

store.on('load', function() {

    nullbaleColumns = new Array();

    // iterate all data,
    // get all columns whose data is null and push columns into nullbaleColumns
    // you can use store.each()


    // get grid headerCt
    // get all columns
    // hide columns whose data is null

    var columns = grid.headerCt.getGridColumns();
    // hide and show columns according to dataIndex or any other parameters by iterating
    // nullbaleColumns and columns using hide() and show() methods

    columns[4].hide(); // 4th entire column is null, so hide
});
于 2013-09-10T07:39:24.120 に答える