View Full Version : Stores & mapping fields that can be null

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',
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?

27 Jan 2011, 2:16 AM
Ok see that this has been posted before. sorry.