Struggling with the lack of two-way data binding functionality in Kendo UI

Recently, I encountered a challenge with my kendo-dropdownlist component. Initially, I was fetching data from an API using the kendo-datasource and everything was working smoothly. However, as I started to implement multiple instances of the kendo-dropdownlist, it became apparent that making separate API calls for each component wasn't efficient.

The solution was to make a single API call and have all the kendo-dropdownlist components retrieve their data from the same JSON response. Each dropdown list is linked to the "currentData" property, making it essential for all components to be synchronized in real-time.

To achieve this, I decided not to assign a data-source-ref to each kendo-dropdownlist. Instead, I used the local data property "source," which stores an array of JSON objects to populate the dropdown items.

During the mounting phase of the component, I trigger an API call to fetch the necessary data and update the "source" property accordingly. This successfully populates the dropdown items, although the "currentData" selection remains unaffected.

Below is a snippet of the component template and script:

<kendo-dropdownlist
  v-model="currentData"
  :data-source="source.filter(s => s.type == 'something')"
  data-text-field="name"
  data-value-field="Id"
></kendo-dropdownlist>
export default {
  name: "SomeComponent",
  props: {
    prop1: String
  },
  data() {
    return {
      currentData: this.prop1,
      source: []
    };
  },
  mounted: async function() {
    await this.setDataSource();
  },
  methods: {        
    async setDataSource() {
      const formDTO = await SERVICE.getDataSource();
      this.source = formDTO.stakeholders;
    }
  }
};

I verified that one of the objects in the sources array has its Id property matching this.prop1.

Answer №1

Within your mounted lifecycle hook, you have implemented the setDataSource function without referencing it properly.

To correctly call the function, use:

await this.setDataSource()

Instead of:

await setDataSource()

By clicking on any data, you can view the corresponding information within the <p></p> tag.

Check out the updated StackBlitz Link: Here is the functional Stackblitz

I hope this explanation clarifies things for you!

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Passing a JSON object between pages in Next.js using props during programmatic navigation

In my Next.js project, I have two pages. On the first page, the user fills out a form to create a post. The information is stored in a large JSON object, which needs to be passed to the second page for the user to preview the post before finalizing it. Wi ...

How to send arrays through JSON?

I have some PHP code: $ids = array(1,2,3); $names = array("cat","elephant","cow"); $originalSettings = array ('ids'=>$ids,'names'=>$names); $jsonSettings = json_encode($originalSettings); echo $jsonSettings; Here ...

Positioning pop-up windows using Javascript and CSS techniques

In my web application, there is a search field that allows users to enter tags for searching. The window should pop up directly below the search field as shown in this image: Image I am trying to figure out how the window positioning is actually d ...

Exploring issues with jQuery

I'm encountering an issue with my code. I have multiple divs with the same classes, and when I click on (toggle#1) with the .comments-toggle class, all divs below toggle-container expand. What I actually want is for only the div directly below .commen ...

Single jQuery scrolling loader malfunctioning in WebKit browser

I've been conducting an interesting experiment in which new entries are dynamically loaded onto a page as you scroll down. Check out a practical demonstration here. In Firefox, everything seems to be working perfectly. However, when viewed in WebKit ...

Differences Between Vuetify Breakpoints and CSS Helper Classes

As I browse through the Vuetify documentation and various code snippets on the web, I often come across examples that mention using either a Vuetify breakpoint or a CSS helper class to make an element responsive to screen size changes. Is there a preferre ...

The Input element's onChange event is not functioning as expected

I am experiencing some issues with my code. I am trying to dynamically change the background color based on user input, but I am struggling to make it work. It seems like a simple task, so I must be missing something. Below is my HTML markup and jQuery: ...

Retrieving data from a material-ui Button component in a React application

I'm currently working with a function that looks like this: handleChangeButton = (e) => { alert(e.target.value) this.props.setFieldValue('degreeLevel', e.target.value); } Within my component's render function, I have the ...

Set JSON Value Session

In the table, there is an option to edit certain entries using a button. I have developed a function that retrieves JSON data and populates the table with it. This process happens before any other actions. Once the data is loaded, my goal is to create a c ...

What is the best way to ensure that an iframe adjusts its height to fit the content within a tabbed container?

Is there a way to dynamically set the height of an iframe to match the content inside it when clicking on a tabbed plane? Initially, I used a fixed height of 1000px. How can this be achieved? <div class="container-fluid text-center"> <div ...

Retrieving data from a script within a React component

How can I access a variable from a script inside a React component? I am performing device detection on Node and sending the resulting object to the client (React) within index.ejs. <script type="text/javascript">window.deviceType = <%- deviceT ...

Establishing the first display in AngularJS with the Ionic Framework

Is there a better way to set the initial screen in my Ionic framework application based on whether or not the user is logged in? In the angular.module.config section, I currently use this approach: if (window.localStorage.getItem("userKey") != null) $ ...

The functionality of Bootstrap tabs is compromised when used within a modal dialog

I am encountering an issue while using Django and Bootstrap to implement nav-tabs within a modal that is displayed upon clicking a button. The problem lies in the fact that when a tab is clicked, its content does not appear. Below is a basic example: {% ...

Creating a custom URL following a redirect in Contact Form 7 to ensure a unique

This is the code I am currently using: <script type="text/javascript> document.addEventListener( 'wpcf7mailsent', function( event ) { location = 'https://www.example.com/thank-you/'; }, false ); </script> With this ...

Unique text: "Custom sorting of JavaScript objects in AngularJS using a special JavaScript order

I'm working with an array structured like this: var myArray = []; var item1 = { start: '08:00', end: '09:30' } var item2 = { start: '10:00', end: '11:30' } var item3 = { start: '12:00& ...

A proposal for implementing constructor parameter properties in ECMAScript

TypeScript provides a convenient syntax for constructor parameter properties, allowing you to write code like this: constructor(a, public b, private _c) {} This is essentially shorthand for the following code: constructor(a, b, _c) { this.b = b; thi ...

Troubleshooting issues with parsing JSON responses in AngularJS

Being new to using AngularJS, I am encountering an issue with parsing a JSON response. I have user login credentials such as Username and password, and I am attempting to parse them when the user clicks on the login button(). If the username and password m ...

Is it possible to integrate Express 4 standalone middleware into an Express 3 application?

While I am not yet prepared to upgrade my Express 3 installation to Express 4, I am interested in utilizing some of the enhanced components in Express 4, such as express-session and compression. I have experimented with implementing these upgrades and eve ...

Transform the Material UI grid orientation to horizontal row for content display

I'm just starting out with material UI and I've put together a grid that includes two components - an autocomplete and a button. Right now, they're stacked on top of each other, but I want to align them side by side in a row. Here's the ...

Switch between classes based on the query using the Ajax response

In order to retrieve data from a database and determine if the field "is_recurring" is set to 1 or 0, I am utilizing an ajax call to my functions.php file. This value is based on a selection made in a dropdown menu. Depending on the result returned by the ...