PDA

View Full Version : Unable to read edited data in extjs Grid



Aashu
22 Jan 2014, 7:53 PM
I am new in ext js and wanted to do some POC for Grid. I need to read the data from oracle database and click on editor updater and then get that updated that and then pass it to a servlet for editing.
I did till rendering data from Database but now unable to prodeed as not getting how to get updated data and pass it to servlet.
Please find my code for Grid -

Ext.require([
'Ext.grid.*',
'Ext.data.*',
'Ext.util.*',
'Ext.state.*'
]);

// Define Person entity
// Null out built in convert functions for performance *because the raw data


Ext.onReady(function() {


Ext.QuickTips.init();

// setup the state provider, all state information will be saved to a cookie
Ext.state.Manager.setProvider(Ext.create('Ext.state.CookieProvider'));


Ext.define('person', {
extend: 'Ext.data.Model',
fields: [


{name: 'sso', type: 'string'},
{name: 'fname', type: 'string'},

{name: 'lname', type: 'string'},
{name: 'msso', type: 'string'},
{name: 'email_address', type: 'string'},
{name: 'person_status', type: 'string'}
]
});

var ds = new Ext.data.Store({
model:'person',
autoLoad: true,
//url:'/FormAction',
actionMethods: {create: "POST", read: "POST", update: "POST", destroy: "POST"},
proxy: {
type: 'ajax',
url: '/identityiq/FormAction',
reader: {
type: 'xml',
record: 'record'
},
}

});

var cellEditing = Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1
});

// create the Grid
var grid = Ext.create('Ext.grid.Panel', {
store: ds,
columns: [
{
text : 'SSO',
width:80,
sortable : true,
dataIndex: 'sso'
},
{
id: 'fname',
header: 'First Name',
dataIndex: 'fname',
width:80,
flex: 1,
field: {
allowBlank: false
}
},
{

id: 'lname',
header : 'Last Name',
width:80,
sortable : true,
dataIndex: 'lname',
field: {
allowBlank: false
}
},
{
text : 'Manager SSO',
width : 80,
sortable : true,
dataIndex: 'msso'
},
{
text : 'Email Address',
width : 80,
sortable : true,
dataIndex: 'email_address'
},
{
text : 'Personstatus',
width : 35,
sortable : true,
dataIndex: 'person_status'
}
],
selModel: {
selType: 'cellmodel'
},
height: 350,
width: 600,
title: 'Array Grid',
renderTo: 'myDiv',
viewConfig: {
stripeRows: true,
enableTextSelection: true
},
frame: true,
tbar: [
{
text: 'Save',


handler: function ()
{
// myGrid is a reference to your Ext.grid.Panel instance
if (grid.editingPlugin.editing) {


var value = grid.editingPlugin.getActiveEditor().field.value;

alert('Value: ' + value);
}
}
}
],
plugins: [cellEditing]
});
});

in this code i am getting error that TypeError: grid.editingPlugin.getActiveEditor(...) is null Request you to please answer this as i am stuck and need to present this POC.
Thanks in Advance.

Also Can you please guide me how to refer documentation and code. I never did a script coding so I am finding it difficult to see documentation and code.

Farish
23 Jan 2014, 12:27 AM
Try this:

var value_field1 = grid.plugins[0].getEditor().getValues().field1;

where field1 is the field of which you want to get value of. you can get value of any field like this.

You can find documentation, examples etc. on this link: http://docs.sencha.com/extjs/4.2.2/

Aashu
23 Jan 2014, 11:15 AM
Thanks for the Answer but this code is giving an error that TypeError: d is undefined. I am not sure how to debug this error.

But i used ds.getModifiedRecords() which is returning all the modified records in the grid.

Thanks Again.