View Full Version : Record with variable number of fields?

15 Jun 2009, 10:17 AM
I want to create a record with n number of fields, where n is a variable with value determined during run time, each fields has a name and a mapping from xml file. codewise it would look like this:

myRecord = new Ext.data.Record.create([

but since the value of n is not fixed, i cannot hardcode the number of fields in the create method, so is there any other method that does the trick?

thank for your help.

15 Jun 2009, 10:48 AM
No, but to create a factory method to create a list of mappings is trivial.

15 Jun 2009, 11:06 AM
can you elaborate on how to create the factory method?

15 Jun 2009, 11:08 AM
Google "Factory pattern"

basically it's a method that returns a new instance of something, thus a 'factory'

15 Jun 2009, 11:20 AM
thanks, i know what should i do now.

what a silly question was this:s..

15 Jun 2009, 11:30 AM
loop through the object and create your record field list. Where in the streaming json do you have a list of fields?