bootstrap使用x-editable的坑(一)

情况:bootstrap table 使用x-editable 进行行内编辑,进行编辑的有普通文本(text)、下拉框(select)、复选框(checklist)等。
后台 是java使用net.sf.json.JSONObject的toBean方法进行将json数组转化为vo对象的,但 x-editable的复选框(checklist)传递到后台的是一个jsonarray对象,而不是普通的String数据,所以net.sf.json.JSONObject的toBean方法无法进行解析处理,会报错并停止下一步,所以处理方式如下:
//将后台传递的json字符串转化为jsonArray
JSONArray jsonRows = JSONArray.fromObject(changeRows);
//通过for jsonRows取得jsonObject
jObject = JSONObject.fromObject(jsonRows.get(i));
//取得sloginterminal,因为该属性传递的是json数组形式,需要自行拼接字符串,然后再设置到属性中。。。
Object tempSloginterminalObj = jObject.get("sloginterminal") ;
JSONArray tempSloginterminalJArray = (JSONArray) tempSloginterminalObj ;
//再通过for tempSloginterminalJArray,即可取得复选框所取得的数据,然后进行所需要的处理。最后再将处理后的数据设置到jObject中。jObject.put("sloginterminal",sLoginterminalSBuffer.toString());

猜你喜欢

转载自blog.51cto.com/13588844/2164695