使用< select>时如何在jqGrid中获取select的值.列上的editoptions [英] How to get select's value in jqGrid when using <select> editoptions on a column

查看:555
本文介绍了使用< select>时如何在jqGrid中获取select的值.列上的editoptions的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在jqGrid中有几列具有edittype ="select"的列.如何读取特定行中当前选择的值的选项值?

I have a couple of columns in jqGrid with edittype="select". How can I read the option value of the value currently selected in a particular row?

例如:当我提供以下选项时,如何获得FedEx等的"FE".

e.g.: When I provide the following option, how do I get "FE" for FedEx, etc.

editoption: { value: "FE:FedEx; IN:InTime; TN:TNT" } 

rowId/cellname的getRowData()仅返回选择的文本/显示部分.

getRowData() for the rowId/cellname returns only the text/displayed component of the select.

如果我在该列上设置了一个更改"数据事件,则仅在单击鼠标时才会触发更改事件,而不会在键盘选择上触发更改事件(有很多关于通用选择和鼠标/键盘问题的引用).

If I set a "change" data event on the column, the underlying fires change events only on mouse clicks, and not keyboard selects (there's numerous references to generic selects and mouse/keyboard issues).

底线,当选择一个新的值,我需要知道在变化的时间的选项值,并且还之前发布到服务器.

Bottomline, when a new value is selected, I need to know the option value at the time of the change, and also prior to posting to the server.

推荐答案

The documentation for getRowData states:

在编辑行或单元格时不要使用此方法.这将返回单元格内容,而不是输入元素的实际值

Do not use this method when you editing the row or cell. This will return the cell content and not the actuall value of the input element

调用getRowData()时行是否仍在编辑?

Is the row still being edited when you call getRowData()?

更新

同意,jqGrid不能很好地处理<select>.在我的应用程序中,我实际上可以通过不指定编辑选项来解决此问题(意思是,键/值都为"FedEx");然后在服务器上完成到ID的转换.这不是正确的编码方式,但对于我当时的需求而言,它已经足够好了.

Agreed, jqGrid does not handle <select> very well. In my application I actually was able to get around this by not specifying an edit option (meaning, key/value were both "FedEx"); the translation to ID is then done on the server. This is not the right way to code this, but it worked well enough for my needs at the time.

这篇关于使用&lt; select&gt;时如何在jqGrid中获取select的值.列上的editoptions的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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