Skip to content

Commit

Permalink
- fix getObjectValue function do not immediately return value when ob…
Browse files Browse the repository at this point in the history
…j[key] is null.

- add `load-on-start` property. when set to `false`, vuetable wll not load the data from the server during the start.
ratiw committed Apr 18, 2016
1 parent 7153936 commit a635491
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions src/vue-table.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* vue-table.js v1.0.4
* vue-table.js v1.0.5
* (c) 2016 Rati Wannapanop
* Released under the MIT License.
*/
@@ -185,7 +185,7 @@ Vue.component('vuetable', {
+ '{{{ callCallback(field, item) }}}'
+ '</td>'
+ '<td v-else class="{{field.dataClass}}">'
+ '{{ getObjectValue(item, field.name) }}'
+ '{{ getObjectValue(item, field.name, "") }}'
+ '</td>'
+ '</template>'
+ '</template>'
@@ -331,6 +331,12 @@ Vue.component('vuetable', {
}
}
},
loadOnStart: {
type: String,
default: function() {
return 'true'
}
},
},
data: function() {
return {
@@ -508,14 +514,16 @@ Vue.component('vuetable', {
},
getObjectValue: function(object, path, defaultValue) {
defaultValue = (typeof defaultValue == 'undefined') ? null : defaultValue

var obj = object
if (path.trim() != '') {
var keys = path.split('.')
keys.forEach(function(key) {
if (typeof obj[key] != 'undefined') {
if (typeof obj[key] != 'undefined' && obj[key] !== null) {
obj = obj[key]
} else {
return defaultValue
obj = defaultValue;
return
}
})
}
@@ -551,6 +559,8 @@ Vue.component('vuetable', {
},
created: function() {
this.normalizeFields()
this.loadData()
if (this.loadOnStart == 'true') {
this.loadData()
}
}
})

0 comments on commit a635491

Please sign in to comment.