DevExtreme Angular - Templates - DevExtreme Angular Documentation (2024)

jQuery

Templates are passed as properties that end with ...Template. Each template has access to the following parameters:

  • data
    A data source object or an object with fields specific to a particular template. For information on the contents of data, refer to the Template Data section of the template's API reference article.

  • index
    A zero-based index of the item in the collection. Can be available only in collection UI component templates.

  • element
    A jQuery element that represents the UI component element being customized. Available only if you use jQuery.

The following code shows how to declare a template and use these parameters. This code declares an itemTemplate for the List UI component:

index.js

$(function() { $("#listContainer").dxList({ items: [ { itemProperty: "someValue" }, // ... ], itemTemplate: function (data, index, element) { return index + " - " + data.itemProperty; // ===== or using the "element" parameter ===== const $item = $("<div>").text( index + " - " + data.itemProperty ); element.append($item); } });});
Angular

Templates are passed as properties that end with ...Template. Each template has access to the following parameters:

  • data
    A data source object or an object with fields specific to a particular template. For information on the contents of data, refer to the Template Data section of the template's API reference article.

  • index
    A zero-based index of the item in the collection. Can be available only in collection UI component templates.

The following code shows how to declare a template and use these parameters. This code declares an itemTemplate for the List UI component:

app.component.html

app.component.ts

app.module.ts

<dx-list [items]="listData" itemTemplate="list-item"> <div *dxTemplate="let data of 'list-item'; let index = index"> {{index}} - {{data.itemProperty}} </div></dx-list>
import { Component } from '@angular/core';@Component({ selector: 'app-root', templateUrl: './app.component.html', styleUrls: ['./app.component.css']})export class AppComponent { listData = [ { itemProperty: "someValue" }, // ... ]}
import { BrowserModule } from '@angular/platform-browser';import { NgModule } from '@angular/core';import { AppComponent } from './app.component';import { DxListModule } from 'devextreme-angular';@NgModule({ declarations: [ AppComponent ], imports: [ BrowserModule, DxListModule ], providers: [ ], bootstrap: [AppComponent]})export class AppModule { }
Vue

Templates are passed as properties that end with ...Template. Each template has access to the following parameters:

  • data
    A data source object or an object with fields specific to a particular template. For information on the contents of data, refer to the Template Data section of the template's API reference article.

  • index
    A zero-based index of the item in the collection. Can be available only in collection UI component templates.

The following code shows how to declare a template and use these parameters. This code declares an itemTemplate for the List UI component:

App.vue

<template> <DxList :items="listData" item-template="list-item"> <template #list-item="{ data, index }"> {{ index }} - {{ data.itemProperty }} </template> </DxList></template><script>import 'devextreme/dist/css/dx.light.css';import DxList from 'devextreme-vue/list';export default { components: { DxList }, data() { return { listData: [ { itemProperty: 'someValue' }, // ... ] } }}</script>
React

Templates are passed as properties that end with ...Render or ...Component. Each template has access to the following parameters:

  • data
    A data source object or an object with fields specific to a particular template. For information on the contents of data, refer to the Template Data section of the template's API reference article.

  • index
    A zero-based index of the item in the collection. Can be available only in collection UI component templates.

The following code shows how to declare a template and use these parameters. This code declares an itemRender for the List UI component:

App.js

import React from 'react';import 'devextreme/dist/css/dx.light.css';import List from 'devextreme-react/list';const renderListItem = (data, index) => { return ( <div>{index} - {data.itemProperty}</div> );}class App extends React.Component { listData = [ { itemProperty: 'someValue' }, // ... ]; render() { return ( <List items={this.listData} itemRender={renderListItem} /> ); }}export default App;

Collection UI components are components that include the items property. These components also support templates for individual items. Do not specify the UI component's dataSource property if you use individual templates.

jQuery

index.js

$(function() { $("#listContainer").dxList({ items: [{ template: function () { return $("<i>").text("Item 1") } }, { template: function () { return $("<b>").text("Item 2") } },{ template: function () { return $("<div>").append( $("<span>").text("Item with nested component"), $("<div>").dxButton({ text: "Click me" }) ) } }] });});
Angular

Declare named templates within the component's markup but outside the templated element. Non-named templates should be declared inside the templated element.

app.component.html

app.module.ts

<dx-list> <dxi-item> <i>Item 1</i> </dxi-item> <dxi-item> <b>Item 2</b> </dxi-item> <dxi-item> <div *dxTemplate> Item with a nested component <dx-button text="Click me"></dx-button> </div> </dxi-item></dx-list>
import { BrowserModule } from '@angular/platform-browser';import { NgModule } from '@angular/core';import { AppComponent } from './app.component';import { DxListModule, DxButtonModule } from 'devextreme-angular';@NgModule({ declarations: [ AppComponent ], imports: [ BrowserModule, DxListModule, DxButtonModule ], providers: [ ], bootstrap: [AppComponent]})export class AppModule { }
Vue

Declare named templates within the component's markup but outside the templated element. Non-named templates should be declared inside the templated element.

App.vue

<template> <DxList> <DxItem> <template #default> <i>Item 1</i> </template> </DxItem> <DxItem> <template #default> <i>Item 2</i> </template> </DxItem> <DxItem> <template #default> <div> Item with a nested component <DxButton text="Click me" /> </div> </template> </DxItem> </DxList></template><script>import 'devextreme/dist/css/dx.light.css';import DxList, { DxItem} from 'devextreme-vue/list';import DxButton from 'devextreme-vue/button';export default { components: { DxList, DxItem, DxButton }}</script>
React

App.js

import React from 'react';import 'devextreme/dist/css/dx.light.css';import List, { Item } from 'devextreme-react/list';import Button from 'devextreme-react/button';class App extends React.Component { render() { return ( <List> <Item> <i>Item 1</i> </Item> <Item> <i>Item 2</i> </Item> <Item> Item with a nested component <Button text="Click me" /> </Item> </List> ); }}export default App;
Angular
See Also
  • Declare Content in the Markup
Vue
See Also
  • Declare Content in the Markup
React
See Also
  • Declare Content in the Markup
DevExtreme Angular - Templates - DevExtreme Angular Documentation (2024)
Top Articles
The Power Of Makeup Versi Artis Indonesia, Pantes Saja Make Up Nya Mahal!
Dual-SIM-Smartphone Test & Vergleich 2024: Die 11 besten
Scheelzien, volwassenen - Alrijne Ziekenhuis
Use Copilot in Microsoft Teams meetings
Ffxiv Act Plugin
Ups Dropoff Location Near Me
Instructional Resources
Noaa Weather Philadelphia
Tlc Africa Deaths 2021
Buckaroo Blog
Baseball-Reference Com
4Chan Louisville
Https //Advanceautoparts.4Myrebate.com
Job Shop Hearthside Schedule
Nitti Sanitation Holiday Schedule
Bowie Tx Craigslist
Enterprise Car Sales Jacksonville Used Cars
Inside the life of 17-year-old Charli D'Amelio, the most popular TikTok star in the world who now has her own TV show and clothing line
The Ultimate Style Guide To Casual Dress Code For Women
Closest Bj Near Me
Sulfur - Element information, properties and uses
Orange Pill 44 291
Atdhe Net
Japanese Mushrooms: 10 Popular Varieties and Simple Recipes - Japan Travel Guide MATCHA
Filthy Rich Boys (Rich Boys Of Burberry Prep #1) - C.M. Stunich [PDF] | Online Book Share
Gotcha Rva 2022
Cain Toyota Vehicles
Koninklijk Theater Tuschinski
Tamil Movies - Ogomovies
Dell 22 FHD-Computermonitor – E2222H | Dell Deutschland
San Jac Email Log In
Rs3 Bring Leela To The Tomb
Worthington Industries Red Jacket
Productos para el Cuidado del Cabello Después de un Alisado: Tips y Consejos
Bernie Platt, former Cherry Hill mayor and funeral home magnate, has died at 90
Hermann Memorial Urgent Care Near Me
Kelsey Mcewen Photos
Montrose Colorado Sheriff's Department
Indiefoxx Deepfake
Pawn Shop Open Now
Craigslist en Santa Cruz, California: Tu Guía Definitiva para Comprar, Vender e Intercambiar - First Republic Craigslist
Craigslist Rooms For Rent In San Fernando Valley
Sechrest Davis Funeral Home High Point Nc
UWPD investigating sharing of 'sensitive' photos, video of Wisconsin volleyball team
Bf273-11K-Cl
Richard Mccroskey Crime Scene Photos
Craigslist Marshfield Mo
Freightliner Cascadia Clutch Replacement Cost
116 Cubic Inches To Cc
Jimmy John's Near Me Open
Craigslist Monterrey Ca
La Fitness Oxford Valley Class Schedule
Latest Posts
Article information

Author: Corie Satterfield

Last Updated:

Views: 5683

Rating: 4.1 / 5 (62 voted)

Reviews: 85% of readers found this page helpful

Author information

Name: Corie Satterfield

Birthday: 1992-08-19

Address: 850 Benjamin Bridge, Dickinsonchester, CO 68572-0542

Phone: +26813599986666

Job: Sales Manager

Hobby: Table tennis, Soapmaking, Flower arranging, amateur radio, Rock climbing, scrapbook, Horseback riding

Introduction: My name is Corie Satterfield, I am a fancy, perfect, spotless, quaint, fantastic, funny, lucky person who loves writing and wants to share my knowledge and understanding with you.