0

In response to

jQuery UI menu inside a jqGrid cell

My specific implementation of a grid has to call setRowData in numerous places. When setRowData is called, the formatter for the column will get called, and will return the <button>s when the row rebuilds in response to the setRowData.

But in the Menu example, the formatting of the buttons (the calls to .button() and .buttonset()) occur on the loadComplete. Since loadComplete obviously does not run after the setRowData, the buttons in the column display unformatted. So, say we add a button to the body:

<button id="setRowData">Set Row Data</button>

and a click event in the $(function() {})

$("#setRowData").click(function() {
  var $grid = $("#list");
  var data = $grid.jqGrid('getRowData', 1);
  data.name = "Changed!";
  $grid.jqGrid('setRowData', 1, data);
});

If you click on the button, the "My Action" and "Bla Bla" buttons show up unformatted.

Grid with buttons unformatted

So, I am looking for an event which I can hang off the setRowData for when after the <button>s have been added to the dom, so I can call .button() and .buttonset() on them again. I want to use an event, since I have a generalized routine which is doing the setRowData (in another library altogether).

Community
  • 1
  • 1
user1689571
  • 495
  • 1
  • 4
  • 17

1 Answers1

0

Okay, I dug through the JQGrid code, and noticed there was a jqGridAfterGridComplete getting called after the setRowData finishes. So I added a:

$("#list").on("jqGridAfterGridComplete", function() {
    ... call the .button code again
});

to the ready function, and the styles are applied again. There may be a better way, and please feel free to offer one. But this seems to work.

user1689571
  • 495
  • 1
  • 4
  • 17