是否可以在不重新加载的情况下更改JQGrid中行的主要ID? [英] Can I change the primary ID of a row in JQGrid without reloading?

查看:87
本文介绍了是否可以在不重新加载的情况下更改JQGrid中行的主要ID?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在JQGrid中实现内联插入.到目前为止,我的方法是:

I'm trying to implement inline inserting in a JQGrid. My approach thus far is:

  • 使用addRowData在ID = -1的末尾放置空白行
  • 使用editGridRow编辑该行
  • 在服务器上检测到此更新实际上是插入内容,因为ID = -1,并返回新的ID值
  • Use addRowData to put a blank row at the end with ID=-1
  • Use editGridRow to edit that row
  • Detect on the server that this update is actually an insert because ID=-1, and return the new ID value

令人惊讶的是,这种鲁德·戈德堡计划效果很好.但是,为了使其无缝,我想以静默方式更新刚刚添加的行的ID,以便用户可以继续编辑其他列.我宁愿不做grid.trigger("reloadGrid"),因为我失去了对那一行的关注.

Suprisingly, this rube goldberg scheme works pretty well. To make it seamless, though, I'd like to silently update the ID of the row that was just added, so that the user can continue to edit the other columns. I'd rather not do a grid.trigger("reloadGrid"), because I lose focus on that row.

我尝试过

grid.setRowData(-1, { MyPrimaryKeyField: newID });

但这不起作用(它仍然认为该行的ID为-1).是否有一种简单的方法可以更改行的主ID,而无需重新加载整个网格?

but that doesn't work (it still thinks the row's ID is -1). Is there an easy way to change the primary ID of a row without reloading the whole grid?

推荐答案

实际上,您无法通过"setRowData"更改网格主行ID, 但是有一种简单的方法可以做到:

Actually you can't change grids primary row Id by "setRowData", but there is a simple way to do it :

$("#-1").attr('id',newId);

;-)

这篇关于是否可以在不重新加载的情况下更改JQGrid中行的主要ID?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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