Variable number of rows in Data View template

I want to show the following info in a Data View template

Hotel Name
Hotel Category
Star Rating

Room TypesBoard Basis
Single…Room Only
Double en-suite…Continental Breakfast

The problem is that I don’t have a fixed number of rows in each record for the Room Types. Is there any way of telling the template that a particular section must be repeated if the same variables are available more than once?


You may set template using function. In the case you may vary the number rows:


Alexandra I have looked at the sample. Please can you tell me what is the ‘obj’ that is passed to the function?


obj is a data object which a template is called for

Alexandra, please can you tell me how can I create this object? Currently I have an Ajax call which gives me a very large XML. I then extract what I want out of it and then call ‘dv.add’ to create each block and use an html template to format it.

In this situation how can I create object?



P.S. Please could somebody look at my Ajax problem in that section as that is more urgent. Thanks

The template function is called for each data object automatically when the item is rendered. This object is the hash of item properties.

For example if xml is:

<data> <item id="1"> <title>title 1</title> <author>author 1</author> </item> <item id="2"> <title>title 2</title> <author>author 2</author> </item> <data>

template will be called 2 times:

  1. parameter will be {id:1,title:“title 1”,author:“author 1”}
  2. parameter will be {id:2,title:“title 2”,author:“author 2”}