Javascript 如何从网格中获取值并发布它们。EXTJS
我感兴趣的是使用网格自定义编辑表单上的按钮Javascript 如何从网格中获取值并发布它们。EXTJS,javascript,extjs,extjs4,extjs6,extjs6-modern,Javascript,Extjs,Extjs4,Extjs6,Extjs6 Modern,我感兴趣的是使用网格自定义编辑表单上的按钮confirm,从网格中获取值并发布它们 但是我不知道如何getValues()。我无法使用此选项,因为值是在“fieldset”xtype中完成的 如何获取网格值…可能存在某种方法,允许将grideditable插件配置设置为Ajax请求配置参数 我的部分代码: Ext.define('Foresto.model.EditListRenters', { extend: 'Ext.grid.Grid', x
confirm
,从网格中获取值并发布它们
但是我不知道如何getValues()
。我无法使用此选项,因为值是在“fieldset”xtype中完成的
如何获取网格值…可能存在某种方法,允许将grideditable
插件配置设置为Ajax请求配置参数
我的部分代码:
Ext.define('Foresto.model.EditListRenters', {
extend: 'Ext.grid.Grid',
xtype: 'rentlist',
requires: [
'Ext.grid.plugin.Editable',
'Foresto.model.RentsListModel'
],
store: {
model: 'Foresto.model.RentsListModel',
autoLoad: true,
pageSize: 0,
proxy: {
type: 'ajax',
url: '/myownurl',
reader: {
type: 'json',
rootProperty: 'results'
}
}
},
plugins: [{
type: 'grideditable',
triggerEvent: 'doubletap',
enableDeleteButton: true,
formConfig: null,
defaultFormConfig: {
xtype: 'formpanel',
title: 'Редактировать договор',
scrollable: true,
items: {
xtype: 'fieldset'
}
},
toolbarConfig: {
xtype: 'titlebar',
cls: 'hdr2',
height: 46.63,
docked: 'top',
items: [{
xtype: 'button',
ui: 'decline',
cls: 'grbuttons',
text: 'cancel',
align: 'left',
action: 'cancel'
}, {
xtype: 'button',
ui: 'confirm',
cls: 'grbuttons',
text: 'submit',
align: 'right',
action: 'submit',
handler: function() {
var rentset = _.getValues() //how get values??
Ext.Ajax.request({
url: '/myownurl/contract/',
method: 'POST',
params: rentset
})
}
}]
}
}],
columns: [ //my columns]
});
使用
grid.getStore().getModifiedRecords();
获取自上次提交以来添加或更新的所有记录 Extjs使用MVC模式,所以您不需要手动挖掘更改的值。您的数据记录(干净的和脏的)都在存储中,连接由代理管理。网格只是可视化数据的可视化组件,它的插件可以帮助更改数据 不要(重新)在您的功能中创建新请求,但要告诉商店执行此任务:
handler: function () {
form.updateRecord();
form.hide();
grid.getStore().sync();
}
另外,请指定代理参数:
proxy: {
type: 'ajax',
batchActions: true,
url: './myownurl',
actionMethods: {
create: 'POST',
read: 'POST',
update: 'POST',
destroy: 'POST'
},
reader: {
type: 'json',
rootProperty: 'results'
},
writer: {
type: 'json',
root: 'data',
encode: true,
writeAllFields: true,
}
}