Ext js 怎样获得 grid 修改后获取当前行 其他列的值(如主键)
{text:'保存修改',handler:function(){varm=store.modified.slice(0);vartemp=[];Ext.each(m,fu...
{
text:'保存修改',
handler: function(){
var m = store.modified.slice(0);
var temp = [];
Ext.each(m, function(item) {
temp.push(item.data);
// alert(Simid)
});
Ext.lib.Ajax.request(
'POST',
'http://192.168.16.120/123/DataPage.aspx?webAction=updateDeviceInfor&sim_card='+SimID+'&car_num='+CarID,
{success: function(response){
var text=Ext.util.JSON.decode(response.responseText)
Ext.Msg.alert('信息',text);
},failure: function(){
Ext.Msg.alert("错误", "服务器未响应,请稍后重试!");
}},
'data=' + encodeURIComponent(Ext.encode(temp))
);
}
}
我要修改的是CarID 我要怎样通过主键SimID来保存修改?怎样获取到我SimID的值?并通过前台页面打印出来? 展开
text:'保存修改',
handler: function(){
var m = store.modified.slice(0);
var temp = [];
Ext.each(m, function(item) {
temp.push(item.data);
// alert(Simid)
});
Ext.lib.Ajax.request(
'POST',
'http://192.168.16.120/123/DataPage.aspx?webAction=updateDeviceInfor&sim_card='+SimID+'&car_num='+CarID,
{success: function(response){
var text=Ext.util.JSON.decode(response.responseText)
Ext.Msg.alert('信息',text);
},failure: function(){
Ext.Msg.alert("错误", "服务器未响应,请稍后重试!");
}},
'data=' + encodeURIComponent(Ext.encode(temp))
);
}
}
我要修改的是CarID 我要怎样通过主键SimID来保存修改?怎样获取到我SimID的值?并通过前台页面打印出来? 展开
展开全部
以下是一个ext.Grid获取所有选择行ID的函数,返回结果是把所有选择行的ID拼接成用逗号连接的字符串,经测试可用,按你的情况,选择一个就可以达到你的需求了
其中GridPanel1是你的grid,
function getSelectValue() {
var gsm = GridPanel1.getSelectionModel(); //获取选择列
var rows = gsm.getSelections(); //根据选择列获取到所有的行
var selectid = ""
for (var i = 0; i < rows.length; i++) {
selectid += rows[i].get('id') + ","; //此处将ID改为您想要取的值
}
return selectid.substr(0, selectid.length - 1);
}
其中GridPanel1是你的grid,
function getSelectValue() {
var gsm = GridPanel1.getSelectionModel(); //获取选择列
var rows = gsm.getSelections(); //根据选择列获取到所有的行
var selectid = ""
for (var i = 0; i < rows.length; i++) {
selectid += rows[i].get('id') + ","; //此处将ID改为您想要取的值
}
return selectid.substr(0, selectid.length - 1);
}
展开全部
url : 'updateContent!updateContent.action',
method : 'post',
waitTitle : '请稍候',
waitMsg : '正在提交表单数据,请稍候...',
success : function(form, action) {
var store = grid_content.getStore();
var origin = grid_content.getSelectionModel().getSelected().data.origin;
if (store.data.length <= 20) {
var v_content = new content({
contentId : form.findField('contentId').getValue(),
contentTitle : form.findField('content.contentTitle').getValue(),
origin : form.findField('content.origin') ? form.findField('content.origin').getValue() : origin,
publishedTime : form.findField('publishedTime').getValue()
});
var index = store.indexOf(grid_content.getSelectionModel().getSelected());
store.remove(grid_content.getSelectionModel().getSelected());
store.insert(index,v_content);
grid_content.getSelectionModel().selectRow(index);
if (store.data.length > 20) {
store.remove(store.getAt(store.data.length- 1));
}
}
bnfield.reset();
btn.enable();
editContentForm.ownerCt.hide();
},
failure : function(form, action) {
Ext.Msg.show({
title : '错误提示',
msg : '操作失败,请检查数据后提交!',
buttons : Ext.Msg.OK,
fn : function() {bnfield.focus(true);btn.enable();},
icon : Ext.Msg.ERROR
});
}
});
提问者评价
谢谢 搞定了
method : 'post',
waitTitle : '请稍候',
waitMsg : '正在提交表单数据,请稍候...',
success : function(form, action) {
var store = grid_content.getStore();
var origin = grid_content.getSelectionModel().getSelected().data.origin;
if (store.data.length <= 20) {
var v_content = new content({
contentId : form.findField('contentId').getValue(),
contentTitle : form.findField('content.contentTitle').getValue(),
origin : form.findField('content.origin') ? form.findField('content.origin').getValue() : origin,
publishedTime : form.findField('publishedTime').getValue()
});
var index = store.indexOf(grid_content.getSelectionModel().getSelected());
store.remove(grid_content.getSelectionModel().getSelected());
store.insert(index,v_content);
grid_content.getSelectionModel().selectRow(index);
if (store.data.length > 20) {
store.remove(store.getAt(store.data.length- 1));
}
}
bnfield.reset();
btn.enable();
editContentForm.ownerCt.hide();
},
failure : function(form, action) {
Ext.Msg.show({
title : '错误提示',
msg : '操作失败,请检查数据后提交!',
buttons : Ext.Msg.OK,
fn : function() {bnfield.focus(true);btn.enable();},
icon : Ext.Msg.ERROR
});
}
});
提问者评价
谢谢 搞定了
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
我不知道你想在哪个地方获取到simID的值,如果要获得gird选中行的其它列值你可以使用
var records = gridPanel.getSelectionModel().getSelections();//获取选择列
if (records .length > 1) {alert('本操作不允许操作多行');return;} //这句用来判断是否为多行
alert(records[0].data.name); //假如gridPanel列名有name,就可以得到name的值。
所谓girdpanel列名是指:”{header:'名称', width:1000,sortable:true, dataIndex:'name'}“里面的name
var records = gridPanel.getSelectionModel().getSelections();//获取选择列
if (records .length > 1) {alert('本操作不允许操作多行');return;} //这句用来判断是否为多行
alert(records[0].data.name); //假如gridPanel列名有name,就可以得到name的值。
所谓girdpanel列名是指:”{header:'名称', width:1000,sortable:true, dataIndex:'name'}“里面的name
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Ext.getCmp("content.editContentForm").getForm().submit({
url : 'updateContent!updateContent.action',
method : 'post',
waitTitle : '请稍候',
waitMsg : '正在提交表单数据,请稍候...',
success : function(form, action) {
var store = grid_content.getStore();
var origin = grid_content.getSelectionModel().getSelected().data.origin;
if (store.data.length <= 20) {
var v_content = new content({
contentId : form.findField('contentId').getValue(),
contentTitle : form.findField('content.contentTitle').getValue(),
origin : form.findField('content.origin') ? form.findField('content.origin').getValue() : origin,
publishedTime : form.findField('publishedTime').getValue()
});
var index = store.indexOf(grid_content.getSelectionModel().getSelected());
store.remove(grid_content.getSelectionModel().getSelected());
store.insert(index,v_content);
grid_content.getSelectionModel().selectRow(index);
if (store.data.length > 20) {
store.remove(store.getAt(store.data.length- 1));
}
}
bnfield.reset();
btn.enable();
editContentForm.ownerCt.hide();
},
failure : function(form, action) {
Ext.Msg.show({
title : '错误提示',
msg : '操作失败,请检查数据后提交!',
buttons : Ext.Msg.OK,
fn : function() {bnfield.focus(true);btn.enable();},
icon : Ext.Msg.ERROR
});
}
});
url : 'updateContent!updateContent.action',
method : 'post',
waitTitle : '请稍候',
waitMsg : '正在提交表单数据,请稍候...',
success : function(form, action) {
var store = grid_content.getStore();
var origin = grid_content.getSelectionModel().getSelected().data.origin;
if (store.data.length <= 20) {
var v_content = new content({
contentId : form.findField('contentId').getValue(),
contentTitle : form.findField('content.contentTitle').getValue(),
origin : form.findField('content.origin') ? form.findField('content.origin').getValue() : origin,
publishedTime : form.findField('publishedTime').getValue()
});
var index = store.indexOf(grid_content.getSelectionModel().getSelected());
store.remove(grid_content.getSelectionModel().getSelected());
store.insert(index,v_content);
grid_content.getSelectionModel().selectRow(index);
if (store.data.length > 20) {
store.remove(store.getAt(store.data.length- 1));
}
}
bnfield.reset();
btn.enable();
editContentForm.ownerCt.hide();
},
failure : function(form, action) {
Ext.Msg.show({
title : '错误提示',
msg : '操作失败,请检查数据后提交!',
buttons : Ext.Msg.OK,
fn : function() {bnfield.focus(true);btn.enable();},
icon : Ext.Msg.ERROR
});
}
});
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
url : 'updateContent!updateContent.action',
method : 'post',
waitTitle : '请稍候',
waitMsg : '正在提交表单数据,请稍候...',
success : function(form, action) {
var store = grid_content.getStore();
var origin = grid_content.getSelectionModel().getSelected().data.origin;
if (store.data.length <= 20) {
var v_content = new content({
contentId : form.findField('contentId').getValue(),
contentTitle : form.findField('content.contentTitle').getValue(),
origin : form.findField('content.origin') ? form.findField('content.origin').getValue() : origin,
publishedTime : form.findField('publishedTime').getValue()
});
var index = store.indexOf(grid_content.getSelectionModel().getSelected());
store.remove(grid_content.getSelectionModel().getSelected());
store.insert(index,v_content);
grid_content.getSelectionModel().selectRow(index);
if (store.data.length > 20) {
store.remove(store.getAt(store.data.length- 1));
}
}
bnfield.reset();
btn.enable();
editContentForm.ownerCt.hide();
},
failure : function(form, action) {
Ext.Msg.show({
title : '错误提示',
msg : '操作失败,请检查数据后提交!',
buttons : Ext.Msg.OK,
fn : function() {bnfield.focus(true);btn.enable();},
icon : Ext.Msg.ERROR
});
}
});
method : 'post',
waitTitle : '请稍候',
waitMsg : '正在提交表单数据,请稍候...',
success : function(form, action) {
var store = grid_content.getStore();
var origin = grid_content.getSelectionModel().getSelected().data.origin;
if (store.data.length <= 20) {
var v_content = new content({
contentId : form.findField('contentId').getValue(),
contentTitle : form.findField('content.contentTitle').getValue(),
origin : form.findField('content.origin') ? form.findField('content.origin').getValue() : origin,
publishedTime : form.findField('publishedTime').getValue()
});
var index = store.indexOf(grid_content.getSelectionModel().getSelected());
store.remove(grid_content.getSelectionModel().getSelected());
store.insert(index,v_content);
grid_content.getSelectionModel().selectRow(index);
if (store.data.length > 20) {
store.remove(store.getAt(store.data.length- 1));
}
}
bnfield.reset();
btn.enable();
editContentForm.ownerCt.hide();
},
failure : function(form, action) {
Ext.Msg.show({
title : '错误提示',
msg : '操作失败,请检查数据后提交!',
buttons : Ext.Msg.OK,
fn : function() {bnfield.focus(true);btn.enable();},
icon : Ext.Msg.ERROR
});
}
});
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询