PDA

View Full Version : RowEditor Grid Problem



murkrishna
16 Jun 2010, 9:39 PM
Hi,

I created a RowEditor Grid when i try to edit the row there was a error which continuously gets fired.

The error message is "this.getStore is not a function". The error is generated continuously till i refresh the page. (around 200 errors in 3 sec)

My Code is


Admin_DesignationInfo_Grid = function(viewer, config) {
this.viewer = viewer;
Ext.apply(this, config);
this.designationgrid_editor = new Ext.ux.grid.RowEditor({
saveText : "Update",
cancelText: "Cancel",
clicksToEdit: 2, //this changes from the default double-click activation to single click activation
errorSummary: true//, //disables display of validation messages if the row is invalid
});
this.designationinfo = Ext.data.Record.create([
{name: 'designid', type: 'int'},
{name: 'designation', type: 'string'},
{name: 'active', type: 'bool'}
]);

this.designationproxy = new Ext.data.HttpProxy({
api: {
read : indexurl+"admin/getalldesigninfo",
create : indexurl+"admin/adddesigninfo",
update: indexurl+"admin/updatedesigninfo",
destroy: indexurl+"admin/deletedesigninfo"
},
method: 'POST'
});

this.designationreader = new Ext.data.JsonReader ({
root: 'designationinfo',
idProperty: 'designid',
restful: true,
remoteSort: false,
fields: this.designationinfo,
totalProperty: 'totalCount',
messageProperty: 'message',
successProperty: 'success'
});

this.designationwriter = new Ext.data.JsonWriter({
encode: true,
writeAllFields: false // write all fields, not just those that changed
});

this.designationstore = new Ext.data.GroupingStore({
proxy: this.designationproxy,
autoSave: true,
reader: this.designationreader,
writer: this.designationwriter,
sortInfo: {field: 'designation', direction: 'ASC'}
});

this.designationstore.load();

this.designationcolumns = [
new Ext.grid.RowNumberer(),
{
id:'designid',
header: 'Designation Id',
dataIndex: 'designid',
menuDisabled: true,
hidden:true,
width: 40
},{
id:'designation',
header: 'Designation',
dataIndex: 'designation',
menuDisabled: true,
width: 40,
editor: new Ext.form.TextField({
validator: this.designationValidator,
allowBlank: false
})
},{

id: 'active', // +X+ ADDED for autoExpandColumn (below)
header: 'Active?',
dataIndex: 'active',
menuDisabled: true,
xtype: 'booleancolumn',
align: 'center',
trueText: 'Yes',
falseText: 'No',
editor: {
xtype: 'checkbox',
value: 'Y',
inputValue: 'Yes'
}
}
];

Admin_DesignationInfo_Grid.superclass.constructor.call(this, {
height:250,
width:500,
id: 'testfile-grid',
loadMask: {msg:'Loading ...'},
store: this.designationstore,
columns: this.designationcolumns,
stripeRows: true,
autoExpandColumn: 'designation',
autoFill: true,
sm: new Ext.grid.RowSelectionModel({
singleSelect:true
}),

viewConfig:{
forceFit:true
,onRowOver:Ext.grid.GridView.prototype.onRowOver.createSequence(function(e, t) {
if(!this.tip) {
this.tip = new Ext.Tip({renderTo:Ext.getBody()});
}
var row = this.findRowIndex(t);
if(row !== false) {
if(row !== this.lastTipRow) {
this.tip.body.update(this.store.getAt(row).get('designation'));
this.lastTipRow = row;
}
this.tip.showBy(t);
}
})
,onRowOut:Ext.grid.GridView.prototype.onRowOut.createSequence(function() {
this.tip.hide();
this.lastTipRow = false;
})
},
view: new Ext.grid.GroupingView({
markDirty: false
}),
plugins: [this.designationgrid_editor],
loadMask:true,
title:'Designation Information',
bbar: new Ext.PagingToolbar({
store: this.designationstore,
pageSize: 25
})

});
this.designationgrid_editor.on(
'canceledit'
,function(roweditor, forced){
if(forced){
var record = this.designationstore.getAt(0);
if(record.get('designation') === ''){
this.designationstore.remove(record);
this.getView().refresh();
}
}
}
,this
);

};

Ext.extend(Admin_DesignationInfo_Grid, Ext.grid.GridPanel, {
designationValidator : function(val){
var gridStore= this.getStore();
var uniqueValues = gridStore.collect('designation');
var s = this.getSelectionModel().getSelections();
var len = s.length-1;

var map_id = s[len].get('designid');
if(map_id!= null){
uniqueValues.splice(uniqueValues.indexOf(val),1);
}
for(var i = 0;i<uniqueValues.length ; i++){
if(uniqueValues[i] === val){
return "Duplicate Designation!";
}
}
return true;
}

});

new Admin_DesignationInfo_Grid;


Anyone can help me what could be the error in the code.

regards
Murali krishna :-?

carol.ext
17 Jun 2010, 6:34 AM
I would start by looking at where in your own code you call getStore() (I see a call in desgnationValidator, validators can get called a lot so that sounds promising). If I did not immediately see a problem with that call I would set a breakpoint at that line or even just set break on all errors (e.g. in firebug) and see if that is where the problem is. If that is the problem area, then look at the object you are calling getStore() on...is it what you were expecting it to be?

murkrishna
17 Jun 2010, 9:34 PM
hi,

Thanks for the reply.
I think the problem is the object (this - var gridStore= this.getStore(); ) which i am calling.

I am bit confused what object could be used their?

b'cos i tried few options which was incorrect.

How to find the object which is correct?

Thanks again
regards
Murali krishna

dawesi
11 Jul 2010, 8:59 PM
you might want to put your code through jslint (http://www.jslint.com) first, then check your scoping of 'this'