当前位置: 代码迷 >> Web前端 >> 如何提交grid中的数据
  详细解决方案

如何提交grid中的数据

热度:122   发布时间:2012-11-08 08:48:11.0
怎么提交grid中的数据

一、提交Ext.grid.GridPanel 中所有数据

1、前台操作

function saveOperatorFunExt(){

? var store=funExt_grid_center.getStore();
???// 将数据放到另一个数组中
??
?var selFuns = [];
???store.each(function(rec){
????selFuns.push(Ext.util.JSON.encode(rec.data));
???});

???Ext.Ajax.request({// ajax提交删除单据
??????url : _base + '/system/operator!saveOperatorFunExt.so',// 提交路径(必须加'_base')
??????params : {// 参数
???????"funExt" : selFuns,
???????"operator.userId":cell[0].data.userId
??????},// 顶级根节点Id
??????success : function(response, config) {// 成功后执行
???????Ext.Msg.alert("提示", "授特权成功!");
??????},
??????failure : function() {
???????Ext.MessageBox.alert("提示", "授特权失败,请与系统管理员联系");
??????}
?????});//end ajax
??}

2、后台接收

public class OperatorAction extends BaseAction {

?? private List<OperatorFunExt> selFuns;
?? private List funExt;

?? private Operator operator;

?? public String saveOperatorFunExt() throws BusinessException {
??????? String userId = operator.getUserId();
???????
if (funExt != null && funExt.size() > 0) {
??????????? JSONObject jsonObj = null;
??????????? JSONArray array = JSONArray.fromObject(funExt); //将存放json字符串的对象转换为JSONArray类型
??????????? Object[] objArray = array.toArray(); //将JSONArray转换为对象数组
??????????? selFuns=new ArrayList<OperatorFunExt>();
??????????? for(Object obj? : objArray){
??????????????? jsonObj? = JSONObject.fromObject(obj);//将对象类型转换为json对象
??????????????? MorphDynaBean morphDynaBean = (MorphDynaBean)jsonObj.toBean(jsonObj);
??????????????? OperatorFunExt funExt = new OperatorFunExt();
??????????????? funExt.setOperatorFunExt(morphDynaBean);
??????????????? selFuns.add(funExt);
??????????? }
??????????? operatorfunextService.assignOptorResources(userId, selFuns);
??????? }
??????? success = true;
??????? return JSON;
??? }

??? //....变量的get、set方法//

}

?

二、提交Ext.grid.EditorGridPanel 中修改了的数据

1、前台操作?

function saveOperatorFunExt(){

? var store=funExt_grid_center.getStore();
???// 将数据放到另一个数组中
??
?var modified = store.modified.slice(0);
????// 将数据放到另一个数组中
???var selFuns= [];
???Ext.each(modified, function(m) {
???????// 将modified数组中的对象转换为json字符串后存入集合中
???????selFuns.push(Ext.util.JSON.encode(m.data));
????});

???Ext.Ajax.request({// ajax提交删除单据
??????url : _base + '/system/operator!saveOperatorFunExt.so',// 提交路径(必须加'_base')
??????params : {// 参数
???????"funExt" : selFuns,
???????"operator.userId":cell[0].data.userId
??????},// 顶级根节点Id
??????success : function(response, config) {// 成功后执行
???????Ext.Msg.alert("提示", "授特权成功!");
??????},
??????failure : function() {
???????Ext.MessageBox.alert("提示", "授特权失败,请与系统管理员联系");
??????}
?????});//end ajax
??}

2、后台接收

方法和“一”的“后台接收”方法相同

  相关解决方案