格式化程序调用后的JQGrid setRowData事件 [英] JQGrid setRowData event after formatter called

查看:274
本文介绍了格式化程序调用后的JQGrid setRowData事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

回应

jqGrid单元格内的jQuery UI菜单

我对网格的特定实现必须在许多地方调用setRowData.调用setRowData时,将调用该列的格式化程序,并在响应setRowData进行行重建时返回< button> s.

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.

但是在Menu示例中,按钮的格式(对.button()和.buttonset()的调用)发生在loadComplete上.由于loadComplete显然不会在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>

和$(function(){})中的click事件

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);
});

如果单击该按钮,则我的动作"和"Bla Bla"按钮将显示为未格式化.

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

因此,我正在寻找一个事件,可以在将< button> s添加到dom后挂起setRowData,以便可以再次在它们上调用.button()和.buttonset(). .我想使用一个事件,因为我有一个通用的例程正在执行setRowData(总共在另一个库中).

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).

推荐答案

好吧,我仔细研究了JQGrid代码,并注意到setRowData完成后有一个jqGridAfterGridComplete被调用.所以我加了一个:

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
});

到ready函数,然后再次应用样式.也许有更好的方法,请随时提供.但这似乎可行.

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.

这篇关于格式化程序调用后的JQGrid setRowData事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆