0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

【 Kendo UI 】gridの変更を反映したい。

Last updated at Posted at 2020-11-07

画面イベントによるデータの変更などでgridのヘッダ項目を変えたい場合があると思います。
嵌らない人もいらっしゃると思いますが、その対策を紹介します。

cmtフィールドの見出しを変えたい状況です。以下のコードだと反映されません。

javascriptWithJquery

      var cmtField = {field: "cmt", title: "コメント", width: "50px"};
      if (needsChange) {
        cmtField = {field: "cmt", title: "振替先ユニット", width: "50px"};
      }

     var grid = $("#hoge").kendoGrid({
        dataSource: $scope.dataSource,
        scrollable: false,
        editable: true,
        columns: [
          {field: "cd", title: "コード", width: "80px"},
          {field: "cd_nm", title: "コード名", width: "150px"},
          cmtField,
          {field: "ord", title: "表示順序", width: "80px"},
          }
        ]
      });

setOptionsを実行することで再描画してくれるようになります。

javascriptWithJquery
      var cmtField = {field: "cmt", title: "コメント", width: "50px"};
      if ($scope.grp_cd) {
        cmtField = {field: "cmt", title: "振替先ユニット", width: "50px"};
      }

     var grid = $("#hoge").kendoGrid({
        dataSource: $scope.dataSource,
        scrollable: false,
        editable: true,
        columns: [
          {field: "cd", title: "コード", width: "80px"},
          {field: "cd_nm", title: "コード名", width: "150px"},
          cmtField,
          {field: "ord", title: "表示順序", width: "80px"},
          }
        ]
      });
      grid.data("kendoGrid").setOptions({});

DartsetStateとかと同じですね。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?