Data Helpers

Last Updated 3/2/2015
Index, Lister, Detail, Repeat and Pager Helpers

@BRT.Index()

Creates a list of view rows.

@BRT.Lister()

The most basic helper for displaying view records on a page - either Content or Contacts

@BRT.Detail()

Makes a detail page for view data.

@BRT.Repeat()

  Repeats a list of items

@BRT.Pager()


Allows you to page BRT.Index() or BRT.Lister() lists.

Parameters for @BRT.Lister, @BRT.Index and @BRT.Detail

tableId
Required. Specify Content or Contacts depending on the view you are using
Example:
tableId:"Contacts"

viewId
Required. The view id of the view containing the category you want to get
Example:
viewId:"People"

fields
Required. This is the field that contains the category
Example:
fields:new[] {"FirstName", "LastName"}

condition
Optional. Add a condition to filter the records returned
Examples:
condition:<Eq FieldId="PartOfOrganization.Id" Value="641808"/>

condition:(String.IsNullOrEmpty(Request.QueryString["topic"])?null:ConditionMeta.Parse("[Topic.Label]='" + Request.QueryString["topic"] + "'"))

template
Optional. A Razor template; specify the HTML for the output.  
Example:
 template:
    @<div>
         @foreach(EngineRecord record in item) {
              <div>@record.GetString("FirstName") @record.GetString("LastName")</div>
         }
    </div>

itemTemplate
Optional. A Razor template for record in the item EngineRecordList
Example:
 itemTemplate:
    @<div>
         <span>@item.GetString("FirstName")</span>
         <span>@item.GetString("LastName")</span>
    </div>

savedFilters
Optional. Filters from view. The Visible filter is applied by default to all Listers, Detail and Index helpers.
Example: 
savedFilters:new[] {"Approved", "Future"}

sortFields
Optional. A list of the fields to sort the Lister or Index records. If not specified it will default to the SortFields in the view. EngineRecordLists can not be sorted by category, custom or relationship fields.
Example:
sortFields:new[] {"LastName", "FirstName"}

pageSize
Lister and Index only. Optional. The number of records returned by the Lister or Index
Example:
pageSize:50

options
Index and Lister only.
 Optional. These options override Lister and Index default settings the following options are available:
  • DataHelperExtensions.DataHelperOptions.PushToChildren
    Applies the condition and savedFilter to any child records
     
  • DataHelperExtensions.DataHelperOptions.ShowInvisible
    Ignores the Visible SavedFilter
Example:
options:DataHelperExtensions.DataHelperOptions.PushToChildren

pagerParams
Index only. Optional. Set the options, spanPages and template for the Pager helper used by the index
Example: 
pagerParms:

Building a Template for BRT.Index, BRT.Lister, and BRT.Detail
Accessing the item

For the Index and Lister you can specify a itemTemplate or template; the Detail only allows a template.

Building a Template

Use the following methods to display data in a template

Category Fields
@foreach(CategoryFieldItem catItem in item.GetCategory("MailState")){
     <div>@catItem.Abbrev</div>
     <div>@catItem.Label</div>
}
To access just the first item in a category field use GetFirstCategoryLabel()
<div>@item.GetFirstCategoryLabel("MailState")</div>
<div>@item.GetFirstCategoryAbbrev("MailState")</div>
Relationship Fields
@foreach(EngineRecord record in item.GetRecordList("Authors")){
     <div>@record.GetString("FirstName")</div>
}
VarChar
<div>@item.GetString("FirstName")</div>
Integer
<div>@item.GetInteger("ChildCount")</div>
DateTime
<div>@item.GetDateTime("PubDate")</div>
Decimal
<div>@item.GetDecimal("Section")</div>
Boolean/Bit
<div>@item.GetBoolean("Inactive")</div>
Files
@foreach(FileFieldItem r in item.GetFiles("VideoFiles")){
     <div class="well">
           <video width="800" height="600" controls="true">
                <source src="@r.Url" type="@r.ContentType" />
           </video>
           <h3>@r.Title</h3>
           <div>@r.Description</div>
      </div>
}
Double
<div>@item.GetDouble("Section")</div>
Href
Get the link to the unique id for the record.  If the record has a friendly it will use the Friendly and the record Id
<a href="/blogdetail/@item.Href">@item.Title</a>
Title
Get the Title for a record
<div>@item.Title</div>
HasField
Check if the record has a field
@if(item.HasField("Name")?@item.GetString("Name"): @item.GetString("FirstName"))
IsDBNull
Check that a filed has a value
@if(!item.IsDBNull("PubDate")){
...
}

Article Topics

For Developers

Want to learn more?

Call 800-924-5220 or

Free trial