Skip to content

Commit 526ef92

Browse files
Angular and Vue: add named/non-named template examples (DevExpress#7179) (DevExpress#7181)
1 parent 8de50dd commit 526ef92

File tree

1 file changed

+58
-4
lines changed

1 file changed

+58
-4
lines changed

includes/custom-templates.md

Lines changed: 58 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -207,8 +207,6 @@ Collection UI components are components that include the **items** property. The
207207

208208
##### Angular
209209

210-
Declare **named** templates within the component's markup but outside the templated element. **Non-named** templates should be declared inside the templated element.
211-
212210
<!-- tab: app.component.html -->
213211
<dx-list>
214212
<dxi-item>
@@ -246,10 +244,34 @@ Declare **named** templates within the component's markup but outside the templa
246244
})
247245
export class AppModule { }
248246

249-
##### Vue
250-
251247
Declare **named** templates within the component's markup but outside the templated element. **Non-named** templates should be declared inside the templated element.
252248

249+
<!-- tab: app.component.html -->
250+
<!-- Named template (the name is 'pictureCellTemplate'): -->
251+
<dx-data-grid ... >
252+
<dxi-column
253+
dataField="Picture"
254+
[width]="100"
255+
[allowFiltering]="false"
256+
[allowSorting]="false"
257+
cellTemplate="pictureCellTemplate"
258+
></dxi-column>
259+
<div *dxTemplate="let data of 'pictureCellTemplate'">
260+
<img [src]="data.value" />
261+
</div>
262+
</dx-data-grid>
263+
264+
<!-- Non-named template -->
265+
<dx-toolbar>
266+
<dxi-item location="center" locateInMenu="never">
267+
<div *dxTemplate>
268+
<div class="toolbar-label"><b>Tom's Club</b> Products</div>
269+
</div>
270+
</dxi-item>
271+
</dx-toolbar>
272+
273+
##### Vue
274+
253275
<!-- tab: App.vue -->
254276
<template>
255277
<DxList>
@@ -291,6 +313,38 @@ Declare **named** templates within the component's markup but outside the templa
291313
}
292314
</script>
293315

316+
Declare **named** templates within the component's markup but outside the templated element. **Non-named** templates should be declared inside the templated element.
317+
318+
<!-- tab: App.vue -->
319+
<!-- Named template (the name is 'pictureCellTemplate'): -->
320+
<template>
321+
<DxDataGrid ... >
322+
<DxColumn
323+
:width="100"
324+
:allow-sorting="false"
325+
data-field="Picture"
326+
cell-template="pictureCellTemplate"
327+
/>
328+
<template #pictureCellTemplate="{ data }">
329+
<img :src="data.value" />
330+
</template>
331+
</DxDataGrid>
332+
</template>
333+
334+
<!-- Non-named template -->
335+
<template>
336+
<DxToolbar>
337+
<DxItem
338+
location="center"
339+
locate-in-menu="never"
340+
>
341+
<template #default>
342+
<div class="toolbar-label"><b>Tom's Club</b> Products</div>
343+
</template>
344+
</DxItem>
345+
</DxToolbar>
346+
</template>
347+
294348
##### React
295349

296350
<!-- tab: App.js -->

0 commit comments

Comments
 (0)