4
3

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 5 years have passed since last update.

jqGrid で動的に列幅を変更する

Posted at

API はなさそう。

Below are options which can not be changed dynamically when the grid is constructed (If changed they do not have effect or will cause the grid errors). For some of these options there are methods available to change the value.

  • name
  • width
  • resizable
  • label (method avail.)

"wiki:colmodel_options - jqGrid Wiki"
http://www.trirand.com/jqgridwiki/doku.php?id=wiki:colmodel_options

Yes it is not implemented. Currently not possible.

"jQuery Grid Plugin – jqGridChange column width | Help | » Forum"
http://www.trirand.com/blog/?page_id=393/help/change-column-width/

実装を見てみるとドラッグ & ドロップのイベントらしきものに直接列幅変更のロジックが書かれているので、これを呼ぶ。

$("#grid").jqGrid();
// i は 0 から始まる列の index
// new_width は新しい列幅 (pixel)
// マウスイベントを模すため clientX を持つオブジェクトを渡す
$("#grid")[0].grid.dragStart(i, {clientX: 0}, [0, 0, 0]);
$("#grid")[0].grid.dragMove({clientX: new_width});
$("#grid")[0].grid.dragEnd();
4
3
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
4
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?