PDA

View Full Version : Showing error "root is undefined" where i am wrong?



jaisonjames
5 Jan 2011, 10:15 PM
Showing error "root is undefined" where i am wrong? Code below

var myData = {
records : [
{ fname : 'Jaison', lname : 'James'},
{ fname : 'Sreejith', lname : 'K'},
{ fname : 'Ajai', lname : 'Robin'},
{ fname : 'Sandeep', lname : 'U'},
{ fname : 'Jaison', lname : 'James'},
{ fname : 'Sreejith', lname : 'K'},
{ fname : 'Ajai', lname : 'Robin'},
{ fname : 'Sandeep', lname : 'U'},
{ fname : 'Jaison', lname : 'James'},
{ fname : 'Sreejith', lname : 'K'},
{ fname : 'Ajai', lname : 'Robin'},
{ fname : 'Jaison', lname : 'James'},
{ fname : 'Sreejith', lname : 'K'},
{ fname : 'Ajai', lname : 'Robin'},
{ fname : 'Sandeep', lname : 'U'},
{ fname : 'Jaison', lname : 'James'},
{ fname : 'Sreejith', lname : 'K'},
{ fname : 'Ajai', lname : 'Robin'},
{ fname : 'Sandeep', lname : 'U'}
]
};


// Generic fields array to use in both store defs.
var fields = [
{name: 'fname', mapping : 'fname'},
{name: 'lname', mapping : 'lname'}
];

// create the data store
var firstGridStore = new Ext.data.JsonStore({
fields : fields,
data : myData,
root : 'records'
});


// Column Model shortcut array
var cols = [
{ id : 'name', header: "<b>First Name</b>", width: 100, sortable: true, dataIndex: 'fname'},
{header: "<b>Last Name</b>", width: 100, sortable: true, dataIndex: 'lname'}
];

Ext.ns('Ext.ux.form');

Ext.ux.form.SearchField = Ext.extend(Ext.form.TwinTriggerField, {
initComponent : function(){
Ext.ux.form.SearchField.superclass.initComponent.call(this);
this.on('specialkey', function(f, e){
if(e.getKey() == e.ENTER){
this.onTrigger2Click();
}
}, this);
},

validationEvent:false,
validateOnBlur:false,
trigger1Class:'x-form-clear-trigger',
trigger2Class:'x-form-search-trigger',
hideTrigger1:true,
width:180,
hasSearch : false,
paramName : 'query',

onTrigger1Click : function(){
if(this.hasSearch){
this.el.dom.value = '';
var o = {start: 0};
this.store.baseParams = this.store.baseParams || {};
this.store.baseParams[this.paramName] = '';
this.store.loadData({params:o});
this.triggers[0].hide();
this.hasSearch = false;
}
},

onTrigger2Click : function(){
var v = this.getRawValue();
if(v.length < 1){
this.onTrigger1Click();
return;
}
var o = {start: 0};
this.store.baseParams = this.store.baseParams || {};
this.store.baseParams[this.paramName] = v;
var root = this.getRoot(o);
this.store.loadData({params:o});
this.hasSearch = true;
this.triggers[0].show();
}
});

var simple = new Ext.ux.form.SearchField({
store: firstGridStore,
width:240
});

jaisonjames
6 Jan 2011, 12:57 AM
no idea ? :(