I have a grid which displays a list of members. The grid has an actioncolumn called Edit with an icon. If a user clicks on the Edit icon, the window is redirected to another page which contains the Edit User form.
Now the code for my store and grid is as follows:
var userstore = Ext.create('Ext.data.Store', {
storeId: 'viewUsersStore',
model: 'Configs',
autoLoad: true,
proxy: {
type: 'ajax',
url: '/user/getuserviewdata.castle',
reader: { type: 'json', root: 'users' },
listeners: {
exception: function (proxy, response, operation, eOpts) {
Ext.MessageBox.alert("Error", "Session has timed-out. Please re-login and
try again.");
}
}
}
});
var grid = Ext.create('Ext.grid.Panel', {
id: 'viewUsersGrid',
title: 'List of all users',
store: Ext.data.StoreManager.lookup('viewUsersStore'),
columns: [
//{header: 'ID', dataIndex: 'id', hidden: true},
{header: 'Username', dataIndex: 'username'},
{header: 'Full Name', dataIndex: 'fullName'},
{header: 'Company', dataIndex: 'companyName'},
{header: 'Latest Time Login', dataIndex: 'lastLogin'},
{header: 'Current Status', dataIndex: 'status'},
{header: 'Edit',
menuDisabled: true,
sortable: false,
xtype: 'actioncolumn',
width: 50,
items: [{
icon: '../../../Content/ext/img/icons/fam/user_edit.png',
handler: function (grid, rowIndex, colIndex){
var rec = userstore.getAt(rowIndex);
alert("Edit " + rec.get('username')+ "?");
EditUser(rec.get('id'));
}
}]
}
]
});
function EditUser(id) {
window.location = "/user/index.castle";
}
When a user clicks the Edit icon, function EditUser(id) gets called. In that function, window.location redirects the user to the Edit User form (that's what the url stands for).
Now my problem is: how to load member data from the database into the Edit User form?
In other words, if the user clicks on the Edit icon, he/she should be redirected to the Edit User form/window which should then be (automatically) loaded with member data (i.e. Username, Fullname, etc.) from the database (each member has a unique id).
I am not using php but Ext JS and Castle Monorail (MVC). I tried using loadRecord(rec) and that works but the problem is that the grid record does not contain all the data fields that occur in the Edit User form and so the data needs to be loaded from the database and not the record.
For example, the Edit User form has a checkboxgroup called Permissions which is left out in the grid.
Also, the edited member data needs to be saved back to the database.
Anyone have any tips as to how to go about this?
Ext.Ajax.Request
to get the remaining data? – egerardus