Skip to content

Commit

Permalink
add vdtnet as context to self
Browse files Browse the repository at this point in the history
  • Loading branch information
noogen committed Sep 3, 2019
1 parent 46d0046 commit 829d6c3
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 9 deletions.
20 changes: 19 additions & 1 deletion example/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -582,6 +582,7 @@ var myUniqueId = 1;
}
},
created: function created() {
var _arguments = arguments;
var vm = this;
var jq = vm.jq;
var orders = [];
Expand Down Expand Up @@ -642,6 +643,16 @@ var myUniqueId = 1;
}

if (field.render) {
if (!field.render.templated) {
(function () {
var myRender = field.render;

field.render = function () {
return myRender.apply(vm, _arguments);
};
})();
}

col.render = field.render;
} // console.log(col)

Expand Down Expand Up @@ -719,6 +730,7 @@ var myUniqueId = 1;
}
},
mounted: function mounted() {
var _arguments2 = arguments;
var vm = this;
var jq = vm.jq;
var $el = jq(vm.$refs.table); // you can access and update the vm.options and $el here before we create the DataTable
Expand Down Expand Up @@ -798,6 +810,10 @@ var myUniqueId = 1;

if (vm.details.template) {
renderFunc = vm.compileTemplate(vm.details.template);
} else if (renderFunc) {
renderFunc = function renderFunc() {
return vm.details.render.apply(vm, _arguments2);
};
} // handle master/details
// Add event listener for opening and closing details

Expand Down Expand Up @@ -861,14 +877,16 @@ var myUniqueId = 1;
data: data,
type: type,
row: row,
meta: meta
meta: meta,
vdtnet: vm
},
render: res.render,
staticRenderFns: res.staticRenderFns
}).$mount();
return jq(comp.$el).html();
};

renderFunc.templated = true;
return renderFunc;
},

Expand Down
2 changes: 1 addition & 1 deletion example/index.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lib/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lib/index.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions lib/mix-manifest.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"/index.js": "/index.js?id=55021534cbb4540829a8",
"/index.js.map": "/index.js.map?id=e2f5e7c9722e176129d1"
"/index.js": "/index.js?id=0e3e5f2010d9eafb45f9",
"/index.js.map": "/index.js.map?id=c05cb93758945419224a"
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "vue-datatables-net",
"description": "Vue jQuery DataTables.net wrapper component",
"version": "1.1.9",
"version": "1.2.0",
"author": "[email protected]",
"license": "MIT",
"main": "lib/index.js",
Expand Down
17 changes: 16 additions & 1 deletion src/VdtnetTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ export default {
buttons: [] // remove any button defaults
},
dataTable: null
vdtnet: this
}
},
computed: {
Expand Down Expand Up @@ -223,6 +224,13 @@ export default {
}
if (field.render) {
if (!field.render.templated) {
let myRender = field.render
field.render = () => {
return myRender.apply(vm, arguments)
}
}
col.render = field.render
}
Expand Down Expand Up @@ -385,6 +393,10 @@ export default {
// must be string template
if (vm.details.template) {
renderFunc = vm.compileTemplate(vm.details.template)
} else if (renderFunc) {
renderFunc = () => {
return vm.details.render.apply(vm, arguments)
}
}
// handle master/details
Expand Down Expand Up @@ -445,14 +457,17 @@ export default {
data: data,
type: type,
row: row,
meta: meta
meta: meta,
vdtnet: vm
},
render: res.render,
staticRenderFns: res.staticRenderFns
}).$mount()
return jq(comp.$el).html()
}
renderFunc.templated = true
return renderFunc
},
/**
Expand Down
3 changes: 2 additions & 1 deletion webpack.mix.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,11 @@ const config = {
umdNamedDefine: true
},
devServer: {
overlay: true,
inline: true,
quiet: false
},
devtool: 'source-map'
devtool: 'cheap-source-map'
};

mix.webpackConfig(config).sourceMaps();
Expand Down

0 comments on commit 829d6c3

Please sign in to comment.