Hi,
I have a Grid which display data from the store. Now I want to edit the data and send it to Server to store into database.
I have wrote code on Grid Edit event
Code:
grid.on('edit', function( e) {
alert('You are Editing'+e.record)
e.record.commit();
});
But still I think the page is not getting submitted on server side.
At the time of loading the page extjs calls "PagingData.jsp" and load data, but when I clicked on the Update button, nothing happens. Please guide me if anything is wrong here.
Can you please tell me what is missing here? Also Can you please tell me the flow how it works in the background?
Here is the code
Store
Code:
var store = Ext.create('Ext.data.Store', {
pageSize: 10,
model: 'ForumThread',
remoteSort: true,
proxy: {
// load using script tags for cross domain, if the data in on the same domain as
// this page, an HttpProxy would be better
autoSave: true,
type: 'jsonp',
url: 'PagingData.jsp?',
reader: {
root: 'topics',
totalProperty: 'totalCount'
},
writer: writer,
// sends single sort as multi parameter
simpleSortMode: true
},
sorters: [{
property: 'Updated_date',
direction: 'DESC'
}]
});
Grid
Code:
var grid = Ext.create('Ext.grid.Panel', {
width: 700,
errorSummary:false,
height: 500,
title: 'Project Listing Grid',
store: store,
disableSelection: true,
loadMask: true,
viewConfig: {
id: 'gv',
trackOver: false,
stripeRows: false,
plugins: [{
ptype: 'preview',
bodyField: 'excerpt',
expanded: true,
pluginId: 'preview'
}]
},
// grid columns
columns:[{
// id assigned so we can apply custom css (e.g. .x-grid-cell-topic b { color:#333 })
// TODO: This poses an issue in subclasses of Grid now because Headers are now Components
// therefore the id will be registered in the ComponentManager and conflict. Need a way to
// add additional CSS classes to the rendered cells.
id: 'topic',
flex:1,
text: "Project Title",
dataIndex: 'title',
sortable: true,
editor: {
// defaults to textfield if no xtype is supplied
allowBlank: false
}
}, {
text: "Created on",
dataIndex: 'Created_date',
width: 220,
align: 'right',
renderer: rendercreatedon,
sortable: true,
field: {
xtype: 'datefield',
allowBlank: false,
format: 'm/d/Y',
minValue: '01/01/2006',
minText: 'Cannot have a start date before the company existed!',
maxValue: Ext.Date.format(new Date(), 'm/d/Y')
}
},{
id: 'last',
text: "Updated on ",
dataIndex: 'Updated_date',
width: 220,
renderer: renderupdatedon,
sortable: true,
field: {
xtype: 'datefield',
allowBlank: false,
format: 'm/d/Y',
minValue: '01/01/2006',
minText: 'Cannot have a start date before the company existed!',
maxValue: Ext.Date.format(new Date(), 'm/d/Y')
}
}],
plugins: [rowEditing],
// paging bar on the bottom
bbar: Ext.create('Ext.PagingToolbar', {
store: store,
displayInfo: true,
displayMsg: 'Displaying topics {0} - {1} of {2}',
emptyMsg: "No topics to display",
items:[
'-', {
text: 'Show Preview',
pressed: pluginExpanded,
enableToggle: true,
toggleHandler: function(btn, pressed) {
var preview = Ext.getCmp('gv').getPlugin('preview');
preview.toggleExpanded(pressed);
}
}]
}),
renderTo: 'topic-grid'
});