[英]How can I populate select boxes with multiple values?
I'm setting up a jqGrid which needs to visualize multiple values in one cell. 我正在设置一个jqGrid,它需要在一个单元格中可视化多个值。 The input comes from a form where the user can select multiple choices.
输入来自表单,用户可以在其中选择多个选项。 I am able to display the select box, but not populate it.
我能够显示选择框,但不能填充它。 I have tried to insert an array in the JSON object, but to no success.
我试图在JSON对象中插入一个数组,但是没有成功。
This is the model: 这是模型:
index:'ship', editoptions:{multiple:true, value:{1:”FedEx”,2:”InTime”,3:”TNT”,4:”ARAMEX”}}
And here are some variations of the data I've tried populating with: 以下是我尝试填充的数据的一些变化:
ship:{[1],[4]}
ship:[[1],[4]]
ship:{value:{1,4}}
...and lots of other variations. ...以及许多其他变化。
I've also searched the jqGrid forum, but didn't find a solution. 我也搜索了jqGrid论坛,但没有找到解决方案。 How can I fix this problem?
我该如何解决这个问题?
Oh boy! 好家伙!
I had the answer all the time. 我一直都有答案。 It was just as easy as I had hoped it would be.
就像我希望的那样简单。
Here's how it's done: 这是完成的过程:
ship:["FedEx","TNT"]
The reason for why I didn't think it worked is because jqGrid shows the data as "FedEx, TNT", thus making me believe it was only a string. 我之所以认为不起作用,是因为jqGrid将数据显示为“ FedEx,TNT”,因此让我相信它只是一个字符串。 Instead of clicking the cell to see what had happend, I spent hours looking for the answer on the internet.
我没有点击单元格查看发生了什么,而是花了数小时在互联网上寻找答案。 If you'd like to know what happends;
如果您想知道发生了什么; jqGrid renders a select list with both elements selected.
jqGrid呈现一个选择列表,其中两个元素均被选中。 Simple.
简单。
Happy jqGrid'ing! jqGrid'ing快乐!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.