Reputation: 956
I'm interested by getValues from my grid and post them, using button confirm
on my grid's custom edit form.
But I haven't idea about how I can getValues()
. I can't use this or it cause values are accomplished inside 'fieldset' xtype.
How I can get to grid values...maybe exist some method, which to allow to set grideditable
plugin config to Ajax request config params?
part of my code:
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]
});
Upvotes: 1
Views: 271
Reputation: 1413
Extjs uses MVC pattern, so you dont need to dig changed values manually. Your data records (clean and dirty ones) are in store, connection is managed by proxy. Grid is just a visual component to visualize the data and its plugins are helpers on changing the data.
Don't (re)create new request inside your function but tell the store to do the job:
handler: function () {
form.updateRecord();
form.hide();
grid.getStore().sync();
}
also, specify proxy parameters:
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,
}
}
Upvotes: 2
Reputation: 361
get the modified records using
grid.getStore().getModifiedRecords();
Gets all records added or updated since the last commit.
Upvotes: 0