@@ -273,6 +273,12 @@ __webpack_require__.r(__webpack_exports__);
273
273
//
274
274
//
275
275
//
276
+ //
277
+ //
278
+ //
279
+ //
280
+ //
281
+ //
276
282
// this demonstrate with buttons and responsive master/details row
277
283
278
284
// import buttons and plugins
@@ -341,9 +347,14 @@ __webpack_require__.r(__webpack_exports__);
341
347
email: {
342
348
label: 'Email'
343
349
},
344
- address: {
345
- label: 'Address',
346
- template: '{{ data.street }}, {{ data.suite }}, {{ data.city }} {{ data.zipcode }}'
350
+ address1: {
351
+ label: 'Address1',
352
+ data: 'address'
353
+ },
354
+ address2: {
355
+ label: 'Address2',
356
+ data: 'address',
357
+ template: '{{ data.city }}, {{ data.zipcode }}'
347
358
},
348
359
phone: {
349
360
label: 'Phone'
@@ -583,20 +594,23 @@ var myUniqueId = 1;
583
594
}
584
595
},
585
596
created: function created() {
586
- var _arguments = arguments;
587
597
var vm = this;
588
598
var jq = vm.jq;
589
- var orders = [];
590
- var startCol = 0;
591
- var icol = 0;
592
599
vm.tableId = vm.id || "vdtnetable".concat(myUniqueId++); // allow user to override default options
593
600
594
601
if (vm.opts) {
595
602
vm.options = jq.extend({}, vm.options, vm.opts);
596
- } // if fields are passed in, generate column definition
603
+ }
604
+ },
605
+ mounted: function mounted() {
606
+ var vm = this;
607
+ var jq = vm.jq;
608
+ var $el = jq(vm.$refs.table);
609
+ var orders = [];
610
+ var startCol = 0;
611
+ var icol = 0; // if fields are passed in, generate column definition
597
612
// from our custom fields schema
598
613
599
-
600
614
if (vm.fields) {
601
615
var fields = vm.fields;
602
616
var cols = vm.options.columns;
@@ -613,8 +627,8 @@ var myUniqueId = 1;
613
627
614
628
var col = {
615
629
title: field.label || field.name,
616
- width: field.width,
617
630
data: field.data || field.name,
631
+ width: field.width,
618
632
name: field.name,
619
633
className: field.className
620
634
};
@@ -639,8 +653,8 @@ var myUniqueId = 1;
639
653
col.searchable = field.searchable;
640
654
}
641
655
642
- if (field.template) {
643
- field.render = vm.compileTemplate(field);
656
+ if (field.template || vm.$scopedSlots[field.name] ) {
657
+ field.render = vm.compileTemplate(field, vm.$scopedSlots[field.name] );
644
658
}
645
659
646
660
if (field.render) {
@@ -649,7 +663,7 @@ var myUniqueId = 1;
649
663
var myRender = field.render;
650
664
651
665
field.render = function () {
652
- return myRender.apply(vm, _arguments );
666
+ return myRender.apply(vm, Array.prototype.slice.call(arguments) );
653
667
};
654
668
})();
655
669
}
@@ -728,13 +742,8 @@ var myUniqueId = 1;
728
742
if (vm.dataLoader) {
729
743
delete vm.options.ajax;
730
744
vm.options.serverSide = false;
731
- }
732
- },
733
- mounted: function mounted() {
734
- var _arguments2 = arguments;
735
- var vm = this;
736
- var jq = vm.jq;
737
- var $el = jq(vm.$refs.table); // you can access and update the vm.options and $el here before we create the DataTable
745
+ } // you can access and update the vm.options and $el here before we create the DataTable
746
+
738
747
739
748
vm.$emit('table-creating', vm, $el);
740
749
vm.dataTable = $el.DataTable(vm.options);
@@ -813,7 +822,7 @@ var myUniqueId = 1;
813
822
renderFunc = vm.compileTemplate(vm.details);
814
823
} else if (renderFunc) {
815
824
renderFunc = function renderFunc() {
816
- return vm.details.render.apply(vm, _arguments2 );
825
+ return vm.details.render.apply(vm, Array.prototype.slice.call(arguments) );
817
826
};
818
827
} // handle master/details
819
828
// Add event listener for opening and closing details
@@ -865,14 +874,30 @@ var myUniqueId = 1;
865
874
* Vue.compile a template string and return the compiled function
866
875
*
867
876
* @param {Object} object with template property
877
+ * @param {Object} the slot
868
878
* @return {Function} the compiled template function
869
879
*/
870
- compileTemplate: function compileTemplate(field) {
880
+ compileTemplate: function compileTemplate(field, slot ) {
871
881
var vm = this;
872
882
var jq = vm.jq;
873
- var res = Vue.compile("<div>".concat(field.template, "</div>"));
883
+ var res = Vue.compile("<div>".concat(field.template || '' , "</div>"));
874
884
875
885
var renderFunc = function renderFunc(data, type, row, meta) {
886
+ var myRender = res.render;
887
+
888
+ if (slot) {
889
+ myRender = function myRender(createElement) {
890
+ return createElement('div', [slot({
891
+ data: data,
892
+ type: type,
893
+ row: row,
894
+ meta: meta,
895
+ vdtnet: vm,
896
+ def: field
897
+ })]);
898
+ };
899
+ }
900
+
876
901
var comp = new Vue({
877
902
data: {
878
903
data: data,
@@ -882,7 +907,7 @@ var myUniqueId = 1;
882
907
vdtnet: vm,
883
908
def: field
884
909
},
885
- render: res.render ,
910
+ render: myRender ,
886
911
staticRenderFns: res.staticRenderFns
887
912
}).$mount();
888
913
return jq(comp.$el).html();
@@ -22122,11 +22147,25 @@ var render = function() {
22122
22147
reloaded: _vm.doAfterReload,
22123
22148
"table-creating": _vm.doCreating,
22124
22149
"table-created": _vm.doCreated
22125
- }
22150
+ },
22151
+ scopedSlots: _vm._u([
22152
+ {
22153
+ key: "address1",
22154
+ fn: function(ctx) {
22155
+ return [
22156
+ _c("span", [
22157
+ _vm._v(
22158
+ _vm._s(ctx.data.street) + ", " + _vm._s(ctx.data.suite)
22159
+ )
22160
+ ])
22161
+ ]
22162
+ }
22163
+ }
22164
+ ])
22126
22165
},
22127
22166
[
22128
22167
_c("template", { slot: "HEAD__details_control" }, [
22129
- _vm._v("\n Show Details\n " )
22168
+ _c("b", [ _vm._v("Show Details")] )
22130
22169
])
22131
22170
],
22132
22171
2
0 commit comments