<template>
<button @click=” treeviewSelected()></button>
<div>
<ejs-treeview
id="main-menubar"
:fields='fields'
ref="treeviewInstance"
:selectedNodes="selectedNodes"
:nodeSelected="nodeSelected"></ejs-treeview>
</div>
</template>
<script>
export default Vue.extend({
data: function() {
let remoteData = new DataManager({
url: 'http://localhost:8080/ '+this.$store.state.userid,
headers: [
{
"Content-Type":
"application/json",
Accept:
"application/json",
Authorization:
"Bearer" +" "+ this.$store.state.id_token
}
],
adaptor: new WebApiAdaptor ,
crossDomain: true,
})
return {
fields: { dataSource: remoteData,
id: 'prog_id', text: 'prog_name'},
}
Method:
treeviewSelected() {
this.remoteData = new DataManager({
url: 'http://localhost:8080/ '+
another.userid,
headers: [
{
"Content-Type": "application/json",
Accept:
"application/json",
Authorization:
"Bearer" +" "+ this.$store.state.id_token
}
],
adaptor: new WebApiAdaptor ,
crossDomain: true,
})
</script>
|
Incorrect ways to update datasource |
Correct way to update datasource
|
|
this.data = new DataManager({
url: 'https://localhost:44356/Home/change_datasource',
adaptor: new WebApiAdaptor,
crossDomain: true,
offline:true
})
treeObj.fields.dataSource = new DataManager({
url: 'https://localhost:44356/Home/change_datasource',
adaptor: new WebApiAdaptor,
crossDomain: true,
offline:true
}) |
treeObj.fields = {dataSource:new DataManager({
url: 'https://localhost:44356/Home/change_datasource',
adaptor: new WebApiAdaptor,
crossDomain: true,
offline:true
}),
id:'prog_id',
text:'prog_name',
parentID:'pid',
hasChildren:'hasChild' } |
|
<ejs-button id="add" class="e-primary" v-on:click.native="treeviewSelected" >Change Datasource</ejs-button>
<div class="control_wrapper">
<ejs-treeview id="main-menubar" :fields="fields" ref="treeviewInstance"></ejs-treeview>
</div>
export default {
name: 'app',
data () {
var data = new DataManager({
url: 'https://localhost:44356/Home/Get',
adaptor: new WebApiAdaptor,
crossDomain: true,
offline:true
});
return {
fields: {
dataSource: data, id: 'prog_id', text: 'prog_name', parentID: 'pid', hasChildren: 'hasChild'
}
}
},
methods: {
treeviewSelected : function(args) {
var treeObj = document.getElementById('main-menubar').ej2_instances[0];
treeObj.fields = {dataSource:new DataManager({
url: 'https://localhost:44356/Home/change_datasource',
adaptor: new WebApiAdaptor,
crossDomain: true,
offline:true
}),
id:'prog_id',
text:'prog_name',
parentID:'pid',
hasChildren:'hasChild' }
}
}
} |
|
UG Documentation |
|
|
Demo link |
|
|
Remote data |
|
|
API reference |
|