peranchine
26 Jan 2011, 4:18 PM
Assume following problem:
A DataView visualizes the following fields: topic, contact person first name and contact person last name.
The store:
store : new Ext.data.JsonStore({
fields : [
{name : 'topic' , mapping : 'topic'},
{name : 'contact_firstname' , mapping : 'contactperson.firstname'},
{name : 'contact_lastname' , mapping : 'contactperson.lastname'}
],
}),
...
The data (1 topic with a contact person, a second one without a contact person):
data = [{
topic: 'topic1',
contactperson:{
firstname: 'contactperson1 firstname',
lastname: 'contactperson1 lastname'
}
},
{
topic: 'topic2'
}]
When loading the store with this data, following error will occur since for 'topic 2' no contactperson has been defined:
obj.contactperson is undefined
[Break On This Error] (function(){var h=Ext.util,k=Ext.each,...lclick",this.onNodeDblClick,this)}});
What is the cleanest way to deal with this problem?
A DataView visualizes the following fields: topic, contact person first name and contact person last name.
The store:
store : new Ext.data.JsonStore({
fields : [
{name : 'topic' , mapping : 'topic'},
{name : 'contact_firstname' , mapping : 'contactperson.firstname'},
{name : 'contact_lastname' , mapping : 'contactperson.lastname'}
],
}),
...
The data (1 topic with a contact person, a second one without a contact person):
data = [{
topic: 'topic1',
contactperson:{
firstname: 'contactperson1 firstname',
lastname: 'contactperson1 lastname'
}
},
{
topic: 'topic2'
}]
When loading the store with this data, following error will occur since for 'topic 2' no contactperson has been defined:
obj.contactperson is undefined
[Break On This Error] (function(){var h=Ext.util,k=Ext.each,...lclick",this.onNodeDblClick,this)}});
What is the cleanest way to deal with this problem?