2017-11-23 11 views
1

私は仕事のためにいくつかの助けが必要です。物語は次のようになります:AG-Grid:サーバーからの応答に基づいて編集可能な列を作成

Item-Id!== nullの場合、「Date」列を編集可能にする必要があります。

私たちには、AG-Gridで作成された受信ボックスがある「ビュー」があります。 受信トレイのようになります:取得中...

public columnDefs = [ 
     {title: Item-Id, editable: this.editable()}, 
     {title: Date, editable: this.editable()}, 
     {title: Justification, editable: this.editable()} 
    ]; 

いくつかのコードを

を:あなたは、オブジェクトを持っているAG-グリッドの列ヘッダを生成するには

---| Item-Id | Date | Justification |--- 
    ---------------------------------------- 
    ---|   |24.05 | text   |--- 
    ---------------------------------------- 
    ---| 31 |25.05 | text 2  |--- 
    ---------------------------------------- 
    ---| 31 |25.05 | text 2  |--- 
    ---------------------------------------- 
    ---|   |24.05 | text   |--- 
    ---------------------------------------- 
    ---|   |24.05 | text   |--- 
    ---------------------------------------- 
    ---| 31 |25.05 | text 2  |--- 
    ---------------------------------------- 

方法私はこのようなものを持っています:

http.get(data).subscribe(response(
     { 
      ...some code... 
      this.editableColumns(response); 
     })); 

    public editableColumns(item: any) { 
     //this method need to return true or false; 
     console.log(response); // [{itemId: null, date: "24.05", justification: "text"},{itemId: 31, date: "24.05", justification: "text"},...etc...}] 
    } 

私は非常にあなたの助けに感謝します。

p.s:列["editable"] = trueなどのメソッドを使用してセルを編集可能にすることはできません。それは動作しません。 trueまたはfalseを返す関数である必要があります。

+0

私はあなたがしたいことはとても簡単だと思いますが、あなたのコードサンプルはちょっと混乱しています... – thirtydot

答えて

0

私は本当に角の構造を知らないが、私はあなたがこのような単純なものしたいと思う:

const columnDefs = [ 
    { 
     headerName: 'Item-Id', 
     field: 'your_id_field', 
    }, 
    { 
     headerName: 'Date', 
     field: 'your_date_field', 
     editable: function(params) { 
      return params.node.data.your_id_field !== null; 
     } 
    }, 
    { 
     headerName: 'Justification', 
     field: 'your_justification_field', 
    }, 
]; 

your_date_fieldセルがyour_id_fieldがNULLでない行のために編集できるようになります。

コード内で動作させるには、必要に応じて変更してください。

+0

IT WORKED.THANK YOU SOO MUCH –

関連する問題