2424 model after the JSON service downloads the data. In some pages defining dynamic
2525 properties may not be needed however it is recommended when using Vue to
2626 avoid unexpected rendering issues.
27+
28+ [data-file-name] is used with [id="download-links"] which is defined
29+ later on this page.
2730 -->
2831
2932 < script
3437 data-page ="jsonData "
3538 data-url ="https://www.dataformsjs.com/data/geonames/countries "
3639 data-load-only-once
37- data-countries >
40+ data-countries
41+ data-file-name ="Countries ">
3842
3943 < h3 v-if = "isLoading" v-i18n = "'Loading...'" > </ h3 >
4044 < p v - if = "hasError" > < span v-i18n = "'Error'" > </ span > - { { errorMessage } } < / p >
@@ -44,27 +48,7 @@ <h1 v-i18n="'Countries'"></h1>
4448 < nav >
4549 < a v-bind :href = "'#/' + i18n_Locale + '/search'" v-i18n = "'Search'" > </ a >
4650 < a v-bind :href = "'#/' + i18n_Locale + '/info'" v-i18n = "'Info'" > </ a >
47- < div class = "download-links ml-20" >
48- < span class = "download" v-i18n = "'Download'" > </ span >
49- < img class = "download"
50- src = "img/Excel.svg"
51- height = "16"
52- width = "16"
53- alt = "Download to Excel"
54- title = "Download to Excel"
55- data-export-excel-selector = "table"
56- data-export-file-name = "[[Countries]].xlsx"
57- v-i18n-attr = "'alt, title, data-export-file-name'" >
58- < img class = "download"
59- src = "img/CSV.svg"
60- height = "16"
61- width = "16"
62- alt = "Download to CSV"
63- title = "Download to CSV"
64- data-export-csv-selector = "table"
65- data-export-file-name = "[[Countries]].csv"
66- v-i18n-attr = "'alt, title, data-export-file-name'" >
67- </ div >
51+ < div class = "ml-20" data-template-id = "download-links" > </ div >
6852 </ nav >
6953
7054 < input
@@ -101,6 +85,41 @@ <h1 v-i18n="'Countries'"></h1>
10185 </ div >
10286 </ script >
10387
88+ <!--
89+ This is an HTML Control which is similar in concept to a Vue or React Component.
90+ This control ends up being included when [data-template-id="download-links"]
91+ is used on the page's HTML.
92+
93+ How it works is DataFormsJS will render all HTML Controls prior to setting
94+ up Vue for the page. [v-bind:data-export-file-name] then uses the attribute
95+ [data-file-name] which is defined on the route to set the attribute value.
96+
97+ Then the DataFormsJS plugin [i18n] handles [v-i18n-attr] to set the value
98+ to the users selected langue. Additionally plugins [exportToExcel, exportToCsv]
99+ are used with this content and set once the page is rendered.
100+ -->
101+ < script type ="text/x-template " data-engine ="vue " id ="download-links ">
102+ < span class = "download" v-i18n = "'Download'" > </ span >
103+ < img class = "download"
104+ src = "img/Excel.svg"
105+ height = "16"
106+ width = "16"
107+ alt = "Download to Excel"
108+ title = "Download to Excel"
109+ data - export - excel - selector = "table"
110+ v - bind :data - export - file - name = "'[[' + fileName + ']].xlsx'"
111+ v - i18n - attr = "'alt, title, data-export-file-name'" >
112+ < img class = "download"
113+ src = "img/CSV.svg"
114+ height = "16"
115+ width = "16"
116+ alt = "Download to CSV"
117+ title = "Download to CSV"
118+ data-export-csv-selector = "table"
119+ v-bind :data-export-file-name = "'[[' + fileName + ']].csv'"
120+ v-i18n-attr = "'alt, title, data-export-file-name'" >
121+ </ script >
122+
104123 < script
105124 type ="text/x-template "
106125 data-engine ="vue "
@@ -109,6 +128,7 @@ <h1 v-i18n="'Countries'"></h1>
109128 data-url ="https://www.dataformsjs.com/data/geonames/regions/:country "
110129 data-load-only-once
111130 data-regions
131+ data-file-name ="Regions "
112132 src ="html/regions-vue.htm ">
113133 </ script >
114134
@@ -120,6 +140,7 @@ <h1 v-i18n="'Countries'"></h1>
120140 data-url ="https://www.dataformsjs.com/data/geonames/cities/:country/:region "
121141 data-load-only-once
122142 data-cities
143+ data-file-name ="Cities "
123144 src ="html/cities-vue.htm ">
124145 </ script >
125146
@@ -151,6 +172,7 @@ <h1 v-i18n="'Countries'"></h1>
151172 data-lazy-load ="json_data, keydownAction, chosen, chosenPlugin "
152173 data-countries ="null "
153174 data-cities ="null "
175+ data-file-name ="Search "
154176 src ="html/search-places-vue.htm ">
155177 </ script >
156178
@@ -205,7 +227,7 @@ <h1 v-i18n="'Countries'"></h1>
205227 ] ,
206228 chosenPlugin : [
207229 // For this demo the [dataBind] plugin is loaded before [chosen]
208- // to make sure that the <select> value will be set before the choosen
230+ // to make sure that the <select> value will be set before the chosen
209231 // control is created. Otherwise the following jQuery code would have
210232 // to be called to trigger the update.
211233 // $('.chosen-select').trigger('chosen:updated');
0 commit comments