"Creating a dynamic TreeList in Ignite UI by linking pairs of names and corresponding

I recently developed a drag and drop tree list inspired by the tutorial on IgniteUI website. The main tree list functions properly, but I encountered an issue with the child nodes displaying as undefined, as illustrated in the image below:

https://i.sstatic.net/PzcW3.png

This is my TypeScript code snippet:

this.settings = {
  checkboxMode: 'triState',
  singleBranchExpand: true,
  dataSource: jQuery.extend(true, [], this.ServiceCounterPointRelations),
  dataSourceType: 'json',
  initialExpandDepth: 2,
  pathSeparator: '.',
  bindings: {
    textKey: 'ServiceCounter',
    valueKey: 'ServiceCounterId',
    childDataProperty: 'ServicePoints'
  },
  dragAndDrop: true,
  dragAndDropSettings: {
    allowDrop: true,
    customDropValidation: function (element) {
      var valid = true,
        droppableNode = jQuery(this);
      if (droppableNode.is('a') && droppableNode.closest('li[data-role=node]').attr('data-value') === 'File') {
        valid = false;
      }

      return valid;
    }
  }
};

The JSON data structure of this.ServiceCounterPointRelations looks like:

"ServiceCounterPointRelations": [
    {
        "ServiceCounterId": 2,
        "ServiceCounter": "Main Counter",
        "ServicePoints": [
            {
                "ServicePointId": 2,
                "ServicePoint": "Service Point 1"
            }
        ]
    },
    ...
]

After investigating, I identified that the problem lies in binding only the parent node's textKey as 'ServiceCounter' and valueKey as 'ServiceCounterId'. As the child nodes have different keys, I am currently exploring solutions to address this mismatch. Any guidance or suggestions on how to handle this situation would be greatly appreciated. Thank you.

Answer №1

The hierarchy of child bindings is crucial for defining data relationships. Using the example, the primary binding layer is at the top level of the data structure. This means that the tree will search for matching text and value keys within this top layer. To define it properly, follow these steps:

bindings: {
    textKey: 'ServiceCounter',
    valueKey: 'ServiceCounterId',
    childDataProperty: 'ServicePoints',
    bindings: {
        textKey: 'ServicePoint',
        valueKey: 'ServicePointId'
    }
},

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 show an array object from PHP to AJAX in JavaScript?

I am facing an issue with a function that returns an array object from PHP using MySQL. I need to call this array in an AJAX function using JavaScript, but I am unsure of how to display the PHP array object in a dynamic table or console log. Here is my PH ...

A guide to displaying a JSON object in a Jade template and iterating through the data

When I pass a JSON string to a jade file for rendering, I am facing an issue where I can only print the entire string and not its individual elements. How can I print specific elements or iterate through the JSON string? app.js: var http = require(&ap ...

What strategies can I use to control the DOM within the onScroll event in ReactJS?

I am currently working on implementing an arrow-up button that should be hidden when I am at the top of my page and displayed once I scroll further down. However, I am facing issues with manipulating the DOM inside my handleScroll function to achieve this. ...

Tips for avoiding an automatic slide up in a CSS menu

Is there a way to disable the automatic slide-up effect on my CSS menu when clicking a list item? I have tried using stop().slideup() function in my JavaScript code, but it doesn't seem to work. Additionally, I would like to highlight the selected lis ...

Passing PHP array to JavaScript in a specific format

After running the code provided, I find that the data returned is in an array format but unfortunately not easily referenced. AJAX: $.ajax({ url: './FILE.php', type: 'post', data: {'action': 'allfolders'}, ...

react-router version 2.0 fails to direct traffic

I'm facing an issue with a piece of code that I have modified from the react-router project page. Despite my modifications, it doesn't seem to work as expected. Configuration In my setup, I have created several simple react components: var Ind ...

Tips for resuming a video playback in HTML5 after pausing it for a brief moment

I am working with a video called introVid, and my goal is for it to pause for 2 seconds when it reaches the 1 second mark before resuming playback. Although I've attempted to achieve this using the code below, the video remains in a paused state after ...

Tips for concealing the values within a selected dropdown list using jQuery

Hello, I'm currently working on a jQuery application that involves a dropdown list box and a gridview. The first column of the gridview has checkboxes with a check all button at the top. My goal is to disable corresponding values in the dropdown list ...

Leveraging ArangoJS Driver within an Angular2 web platform

Currently, I am in the process of working on a project that involves Angular2 and Typescript (v1.8.10). Our aim is to incorporate data from an ArangoDB database into the web application. Ideally, I would like to utilize the arangojs driver for this task. H ...

Tips for integrating pdf.js worker in an Angular CLI project

When utilizing pdf.js directly in an Angular application for various PDF-related tasks, everything seems to be functioning properly. In order to utilize pdf.js, I imported it from pdfjs-dist and added it to my package.json file. Although the PDF works wi ...

How many parameters are typically transmitted through URLs in a nodeJS environment?

Is there a way to identify the number of parameters included in a URL? What approach can I use to count the parameters sent through a URL in nodeJS? ...

Calculating Events with the onChange Method in Typescript

How do I calculate the total ticket price when I adjust the number of individuals? HTML Code : <div class="row"> <div class="col-md-6"> <label for="person">Person</label> <div class="form-group"> ...

Does JSON hijacking play a role with IE versions greater than 10 or Chrome versions greater than 30?

OWASP suggests wrapping json response with an object rather than returning a direct array. For instance: [{"id":5}] Is this vulnerability still relevant? Could it be exploited? After testing in Chrome, IE, and FF, I couldn't find a way to 'h ...

Limiting the scope of TypeScript types to specific keys, such as Exact/DeepExact

After coming across this specific query on SO, I wanted to delve into creating an Exact type. My attempt at implementing something akin to a DeepExact seems to be close: // Desired type that should only accept Exact versions of type Opts = { firstName?: ...

Issues with styled-components media queries not functioning as expected

While working on my React project with styled components, I have encountered an issue where media queries are not being applied. Interestingly, the snippet below works perfectly when using regular CSS: import styled from 'styled-components'; exp ...

Unable to hide the mobile menu button

https://i.sstatic.net/5rdYY.pngI am currently working on a fun website project . I am facing an issue with the mobile menu button not disappearing using display:none in Safari on my iPhone when in landscape mode, even though it works fine in Chrome. My g ...

The type 'EventTarget & HTMLTextAreaElement' does not contain the property 'files'

When trying to call a method in React TypeScript on the onChange Event of a MUI Input field, an error is encountered. The error message received is: Type '(event: { target: { files: any[]; }; }) => void' is not assignable to type 'Chang ...

Using JavaScript to generate dynamic folders in Alfresco is not functioning as expected

Working with Alfresco 4.0.d community edition (also tested on Alfresco 4.0.c) on an Oracle Linux 64-bit virtual machine using Firefox. I've been developing a script to dynamically create sub-folders as new items are added to a space/folder via a rule ...

Storing video blobs in the filesystem using Electron and Node.js

My electron application allows users to record video from their webcam using the MediaRecorder API. After hitting the "stop record" button, I am able to obtain a blob of the recorded video. I am trying to figure out how to convert this blob into a real w ...

Inadvertent scroll actions causing unexpected value changes in Material UI sliders

I am currently working on a React application that utilizes Material UI, with slider components integrated throughout the interface. However, I have encountered an issue when using a touch screen device - unintentional changes to the slider values occur wh ...