1+
2+ <template >
3+ <ax-datagrid :columns =" columns" :rows =" rows" :options =" options" @row =" onRow" >
4+
5+ <template #company =" {data } " >
6+ <div >
7+ <div class =" bold blue" >{{data.customerID}}</div >
8+ <div class =" small" >{{data.companyName}}</div >
9+ </div >
10+ </template >
11+
12+ <template #contact =" {data } " >
13+ <div >
14+ <div class =" bold" >{{data.contactName}}</div >
15+ <div class =" small" >{{data.contactTitle}}</div >
16+ </div >
17+ </template >
18+
19+ <template #address =" {data } " >
20+ <div >
21+ <div class =" small" >{{data.address}}</div >
22+ <div class =" small" >{{data.postalCode}} <span >{{data.city}}</span ></div >
23+ </div >
24+ </template >
25+
26+ <template #country =" {text } " >
27+ <div >
28+ <img :src =" flags[text]" />{{text}}
29+ </div >
30+ </template >
31+
32+ <template #phone =" {data } " >
33+ <div >
34+ <div class =" small phone" >{{data.phone}}</div >
35+ <div class =" small fax" >{{data.fax}}</div >
36+ </div >
37+ </template >
38+
39+ </ax-datagrid >
40+ </template >
41+ <script >
42+
43+ import {components } from ' @activewidgets/vue' ;
44+ import { northwind } from ' @activewidgets/examples/data' ;
45+ import * as flags from ' @activewidgets/examples/flags' ;
46+ import options from ' ./options' ;
47+ import ' ./styles.css' ;
48+
49+
50+ function data (){
51+
52+ const columns = [
53+ { header: ' Company' , template: ' company' , fixed: true },
54+ { header: ' Contact' , template: ' contact' , style: ' background:#f4f4f4' , key: ' contact' },
55+ { header: ' Address' , template: ' address' , key: ' address' },
56+ { header: ' Country' , type: ' country flag' , field: ' country' },
57+ { header: ' Phone/Fax' , type: ' phone & fax' },
58+ { header: ' Last Order' , type: ' money' , field: ' amount' },
59+ { header: ' Order Date' , type: ' date' , field: ' date' }
60+ ];
61+
62+
63+ const rows = Object .freeze (northwind .customers );
64+
65+ return { columns, rows, options, flags };
66+ }
67+
68+
69+ function onRow (row ){
70+
71+ const {data , cells } = row;
72+
73+ // calculated values
74+ cells .amount = 2000 * Math .random ();
75+ cells .date = Date .now () - 500 * 86400000 * Math .random ();
76+
77+
78+ // dynamic row style
79+ if (data .country == ' France' ){
80+ row .class = ' bg-green' ;
81+ }
82+
83+ // dynamic cell styles
84+ if (data .city == ' London' ){
85+ cells .address = {class: ' circle' };
86+ }
87+
88+ if (data .contactTitle == ' Owner' ){
89+ cells .contact = {class: ' star' };
90+ }
91+ }
92+
93+
94+ const methods = { onRow };
95+
96+
97+ export default { components, data, methods };
98+
99+ </script >
0 commit comments