How can I trigger HierarchicalDataSource.read() when the kendoDropDownList's change event is fired?

Currently, I am utilizing the treeview and HierarchicalDataSource features of KendoUI. Additionally, I have included a kendoDropDownList at the top of the page. Each time a user changes the value of the dropdown list, it triggers the 'change' event, causing the HierarchicalDataSource to be read again. However, it seems that the dropdown change event is not functioning as I had anticipated. I have not made a call to HierarchicalDataSource.read(). Any thoughts on what I might be doing wrong?

Dropdownlist

$("#dropdown").kendoDropDownList({
  dataTextField: "functionName",
  dataValueField: "hrsPositionID",
  dataSource: {
  transport:{
    read: {
    url:  "./getDropdown.php",
    type: "POST",
    data: function() {
        return { 
          method: "getDropdown",
        }
      }
    },
  },
  },
  change: function(e){
    console.log(this.value());
    $('#AccountingTree').data('kendoTreeView').HierarchicalDataSource.read();  //<-- not working
  }
}).data('kendoDropDownList');
dropdownlist = $("#dropdown").data("kendoDropDownList");

HierarchicalDataSource & kendoTreeView

var serviceRoot = "./getyzdTreeView.php";   
dataSource = new kendo.data.HierarchicalDataSource({
  transport: {
    read: {
      url: serviceRoot,
      dataType: "json",
      type: "POST",
      data: function(){
        return {
          positionID: dropdownlist.value()  //read the value from dropdownlist 
        }
      }
    }
  },
  schema: {
    model: {
      id : "programID",
      hasChildren: false,
      children : "items"
    }
  },
  filter: { field: "module", operator: "startswith", value: "Accounting" }
});

$("#AccountingTree").kendoTreeView({
  check: onCheck,
  checkboxes: { checkChildren: true } ,
  dataSource: dataSource,
  dataBound: function(){
      this.expand('.k-item');
  },
  dataTextField: ["module","groupname","programName","checked"]
});

Answer №1

I finally discovered the solution. The approach I took was to simply invoke

 update: function(e){
    dataSource.refresh()
 }

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

What is the best way to send props from page.js to layout.js in the Next.js app directory?

Is there a way to effectively pass props to layouts in Next.js 13? Can we optimize the approach? Here's an example: // layout.js export default Layout({children}) { return ( <> {/* Display different `text` based on the page.js being ...

Combining arrays using the jQuery .each() function

I'm attempting to generate an array from several div id's. Check out my code below: $(function(){ $('#content > div[id^=post]').each(function(){ var ele = Number($(this).attr('id').substr(5,4)); var arr ...

How can the CORS issue be resolved when sending a form from a client to an AWS API gateway function?

Within my front end React application, I am looking to implement a contact form that will submit data to a Lambda function via an API Gateway with a custom domain attached. The frontend operates on the domain dev.example.com:3000, while the API Gateway is ...

Having trouble deploying my Express/Next app on Netlify

I am facing issues deploying my Next/Express app on Netlify. While the app functions perfectly locally, I encounter problems when attempting to deploy it using Netlify lambda function. Here are the links to my test git repositories: https://github.com/La ...

The mesmerizing world of Vue templates and transition groups

My previous simple list had transitions working perfectly, but now that I am using components and templates the transitions no longer work. Can anyone help me understand why? I want each item to animate individually, but it seems like all items are transi ...

javascript the debate between inline and traditional registration

Hey there, I'm a JavaScript beginner and currently learning about inline vs. traditional registration. I've managed to get code block 1 (inline) working perfectly fine, but unfortunately, code block 2 (traditional) isn't cooperating. Can som ...

Modifying HTML files in a Node.js environment with the fs module

Struggling with learning node.js and back-end development, I encountered a problem that I can't solve. Can anyone lend a hand? I've been working on changing my HTML page from h1.html to h2.html, but I keep encountering the following error: (Error ...

How can I retrieve all element attributes in TypeScript using Protractor?

I came across this solution for fetching all attributes using protractor: Get all element attributes using protractor However, I am working with TypeScript and Angular 6 and struggling to implement the above method. This is what I have tried so far: im ...

I'm having some trouble with my jQuery.get() function in the javascript Saturday(), can anyone help me figure out what I'm doing wrong?

Can anyone help me troubleshoot my jQuery.get() method in the saturday() JavaScript function? Here is the code snippet I have been working on. This is what I have in my index.html file: <html> <head> <title>jVectorMap demo</title> ...

Struggling with transitioning from TypeScript to React when implementing react-data-grid 7.0.0

I'm trying to add drag and drop functionality to my React project using react-data-grid, but I keep encountering a "TypeError: Object(...) is not a function" error. I have a TypeScript version of the file in the sandbox as a reference, but when I try ...

Issue: Exceeding rendering limit. React has a restriction on the number of renders to avoid endless loops

I'm in the process of creating a basic to do list using React, and I've encountered an issue with the handleSubmit() function that I can't seem to resolve. import React, { useState } from "react"; function TaskList() { const [ta ...

Implementing NgRx state management to track and synchronize array updates

If you have multiple objects to add in ngrx state, how can you ensure they are all captured and kept in sync? For example, what if one user is associated with more than one task? Currently, when all tasks are returned, the store is updated twice. However, ...

Having trouble getting the expected transition effects to work with Vue.js

Currently, I have a display of lists of items through the use of v-for. Initially, only the summary section of each item is visible. Upon clicking on an item, the details section is supposed to appear. This functionality is achieved by adding or removing ...

Building a dynamic form using React Material-UI Autocomplete and integrating it with react

I'm encountering an issue where the MUI Autocomplete is not displaying the selected fields even though the react-hook-form values have been updated. Here is the code snippet import { useForm, Controller, FormProvider } from "react-hook-form" ...

Dynamic row addition in Material Design Lite table causes format to break

Here's the HTML markup for creating a checkbox using material-design-lite: <label class="mdl-checkbox mdl-js-checkbox mdl-js-ripple-effect" for="checkbox"> <input type="checkbox" id="checkbox" class="mdl-checkbox__input" /> <span c ...

The return value from vue-query is ObjectRefImpl, not the actual data

Greetings to the Vue.js community! As a newcomer to Vue.js, I am seeking guidance on fetching data using vue-query, Vue.js 3, and the composition API. The data returned to me is ObjectRefImpl, but when I try to print the values, I encounter the error: "Pro ...

An issue is preventing the Angular 2+ http service from making the requested call to the server

I am looking to create a model class that can access services in Angular. Let's say I have the following endpoints: /book/:id /book/:id/author I want to use a service called BooksService to retrieve a list of Book instances. These instances should ...

Ways to use string functions in JavaScript to substitute with /

Here is the image path I am working with: var str = "D:\Poc\testProject\DataPush\public\unzip\cust\AccountData\2.jpg" When I included "unzip" in the path, it threw an error as shown in this image, but when ...

Ordering products in Angular JS based on whether they are free or not can be done by

I am currently implementing Angular's ng-repeat to showcase products from a JSON feed. My goal is to organize and categorize these products by distinguishing between free items (with the JSON property 'free':true) and those that require a pu ...

Steps for storing API information in localStorage:1. Retrieve the API data

My app is running sluggish due to the excessive API calls for information retrieval. To optimize performance, I want to create a unified object containing all the data that can be shared across pages and accessed from localStorage, thus enhancing the app ...