Skip to content

Commit d76f6b3

Browse files
committed
add comp property
1 parent aa9e002 commit d76f6b3

10 files changed

+609
-370
lines changed

README.md

+8-7
Original file line numberDiff line numberDiff line change
@@ -232,9 +232,9 @@ Custom events for this component.
232232
```
233233

234234
```js
235-
doSomethingImmediatelyAfterTableCreatedAndInitialized(comp) {
236-
// use comp.dataTable to access the jQuery DataTables object, example:
237-
comp.dataTable.on( 'order.dt', function () { eventFired( 'Order' ); } )
235+
doSomethingImmediatelyAfterTableCreatedAndInitialized(vdtnet) {
236+
// use vdtnet.dataTable to access the jQuery DataTables object, example:
237+
vdtnet.dataTable.on( 'order.dt', function () { eventFired( 'Order' ); } )
238238
}
239239
```
240240
- `table-creating` this is right before jQuery(el).DataTable(component.options) is called allowing you to modify component options.
@@ -374,11 +374,11 @@ window.open(url)
374374
## Native templating (sort-of) explained
375375
Take a look at example app, you can template:
376376
```
377-
<template
378-
slot="address1"
377+
<template
378+
slot="address2"
379379
slot-scope="ctx"
380380
>
381-
<span>{{ ctx.data.street }}, {{ ctx.data.suite }}</span>
381+
<span>{{ ctx.data.city }}, {{ ctx.comp.formatCode(ctx.data.zipcode) }}</span>
382382
</template>
383383
```
384384
@@ -391,8 +391,9 @@ Take a look at example app, you can template:
391391
4. `meta` jQuery DataTables column config
392392
5. `vdtnet` the vdtnet table object
393393
6. `def` vdtnet field config
394+
7. `comp` your component, notice how it demonstrate calling of a function on the example component to strip out all number after the dash. You can use this to do things like permission checking. Also see **Note** below.
394395
395-
Things that are related to display rendering should work. Event handling doesn't work and I'm still looking for better way handle this. Of course, you can still use `data-action` to handle clicks.
396+
**Note**: Things that are related to display rendering should work. Event handling doesn't work and I'm still looking for better way handle this. Of course, you can still use `data-action` to handle clicks.
396397
397398
## Export
398399
This is something you want to explore on your own. We try our best to provide as much example of export as possible in our demo, but Server-Side and/or Language/Framework Specific Code is too much/time-consuming to dive into. Also, sometime output rendering are ties to specific requirement and cannot generically meet everyone needs. We suggest that you create a Bounty for your specific needs.

example/app.vue

+8-5
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,10 @@
5454
<b>Show Details</b>
5555
</template>
5656
<template
57-
slot="address1"
57+
slot="address2"
5858
slot-scope="ctx"
5959
>
60-
<span>{{ ctx.data.street }}, {{ ctx.data.suite }}</span>
60+
<span>{{ ctx.data.city }}, {{ ctx.comp.formatCode(ctx.data.zipcode) }}</span>
6161
</template>
6262
</vdtnet-table>
6363
</div>
@@ -123,12 +123,12 @@ export default {
123123
email: { label: 'Email' },
124124
address1: {
125125
label: 'Address1',
126-
data: 'address'
126+
data: 'address',
127+
template: '{{ data.street }}, {{ data.suite }}'
127128
},
128129
address2: {
129130
label: 'Address2',
130-
data: 'address',
131-
template: '{{ data.city }}, {{ data.zipcode }}'
131+
data: 'address'
132132
},
133133
phone: { label: 'Phone' },
134134
website: {
@@ -182,6 +182,9 @@ export default {
182182
const parms = this.$refs.table.getServerParams()
183183
parms.export = type
184184
window.alert('GET /api/v1/export?' + jQuery.param(parms))
185+
},
186+
formatCode(zipcode) {
187+
return zipcode.split('-')[0]
185188
}
186189
}
187190
}

example/index.js

+14-7
Original file line numberDiff line numberDiff line change
@@ -349,12 +349,12 @@ __webpack_require__.r(__webpack_exports__);
349349
},
350350
address1: {
351351
label: 'Address1',
352-
data: 'address'
352+
data: 'address',
353+
template: '{{ data.street }}, {{ data.suite }}'
353354
},
354355
address2: {
355356
label: 'Address2',
356-
data: 'address',
357-
template: '{{ data.city }}, {{ data.zipcode }}'
357+
data: 'address'
358358
},
359359
phone: {
360360
label: 'Phone'
@@ -408,6 +408,9 @@ __webpack_require__.r(__webpack_exports__);
408408
var parms = this.$refs.table.getServerParams();
409409
parms["export"] = type;
410410
window.alert('GET /api/v1/export?' + jQuery.param(parms));
411+
},
412+
formatCode: function formatCode(zipcode) {
413+
return zipcode.split('-')[0];
411414
}
412415
}
413416
});
@@ -893,7 +896,8 @@ var myUniqueId = 1;
893896
row: row,
894897
meta: meta,
895898
vdtnet: vm,
896-
def: field
899+
def: field,
900+
comp: vm.$parent
897901
})]);
898902
};
899903
}
@@ -905,7 +909,8 @@ var myUniqueId = 1;
905909
row: row,
906910
meta: meta,
907911
vdtnet: vm,
908-
def: field
912+
def: field,
913+
comp: vm.$parent
909914
},
910915
render: myRender,
911916
staticRenderFns: res.staticRenderFns
@@ -22150,12 +22155,14 @@ var render = function() {
2215022155
},
2215122156
scopedSlots: _vm._u([
2215222157
{
22153-
key: "address1",
22158+
key: "address2",
2215422159
fn: function(ctx) {
2215522160
return [
2215622161
_c("span", [
2215722162
_vm._v(
22158-
_vm._s(ctx.data.street) + ", " + _vm._s(ctx.data.suite)
22163+
_vm._s(ctx.data.city) +
22164+
", " +
22165+
_vm._s(ctx.comp.formatCode(ctx.data.zipcode))
2215922166
)
2216022167
])
2216122168
]

example/index.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/index.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/index.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/mix-manifest.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
2-
"/index.js": "/index.js?id=4c04c8ae42c454ff0051",
3-
"/index.js.map": "/index.js.map?id=418f15296ccb3ff1d586"
2+
"/index.js": "/index.js?id=0f59f3d0318e83aec294",
3+
"/index.js.map": "/index.js.map?id=7d20b55eb6bd78e18133"
44
}

0 commit comments

Comments
 (0)