Retrieve a Kendo UI model by utilizing drag and drop functionality on a non-Kendo UI element

I'm currently developing a prototype that utilizes Kendo UI Pro with a heavy reliance on the TreeListView and Drag and Drop functionalities. I have implemented a custom drop location using an Angular 1.x custom directive. Within this directive's link method, I am connecting to the element using kendoDropTarget(). My intention was for this method to automatically provide me with the associated Kendo model of the dropped tree row, but it appears that is not the case (unless I am missing something.)

I attempted to set and retrieve the dataTransfer on the object based on information from MDN in this manner:

$scope.treeListOptions = {
  //...
  drag: function (e) {
    e.dataTransfer.setData('text/plain', JSON.stringify(e.source));
   }
};

And within my directive, something similar to:

app.directive('dropLoc', function () {
    return {
    // ...
    link: function (scope, ele, attrs, ctrl) {
        ele.kendoDropTarget({
            dragenter: function (e) {
                var data = e.dataTransfer.getData('text/plain');
                console.log(data);
            }
        });
    }
};

However, the above code leads to an error stating e.dataTransfer is undefined.

Therefore, my inquiry is how can I effectively retrieve the model from a Kendo-enabled widget?

Is it necessary to set up numerous data- attributes?

Answer №1

Although I managed to find a solution for my issue here, I can't help but feel like there should be a more efficient way to handle it. I believe the main problem lies in juggling between two different scopes: the directive and the treelist. Being new to Angular probably doesn't make things easier either. =/

After successfully triggering the drop events and having the necessary data on the source end, I attempted to resolve the issue by creating an Angular service to update the data during the source drop event. However, I soon realized that the target drop event would occur before the source drop event.

To work around this hurdle, I introduced a new custom event that would only be emitted once the data was updated. The target then listened for this event to retrieve the updated data.

It's frustrating to think that even with all the features of this library, I had to struggle so much to make it function properly.

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

Configuring AngularJS and Laravel for nginx to run PHP directly from a URL segment

I'm facing an issue while trying to configure Laravel to run from the /api/ segment of the main domain. The plan is to have the main Angular application served at subdomain.domain.com and the Laravel PHP server configuration at subdomain.domain.com/ap ...

Cross-origin resource sharing (CORS) is preventing access because the origin and allowed origin match

Utilizing Dockerized Ory Kratos and Angular (www folder hosted via nginx for header modifications) on localhost and attempting to run the following code: const headers = { Accept: 'application/json', }; fetch('http://127.0.0.1:4433/self-s ...

eval concealing program in JGraph compared to obfuscation and packing

Many times when the topic of eval is brought up, the response is always the same - avoid using eval. However, I believe there is a valid reason for eval to exist. Nevertheless, there are numerous pitfalls to consider. Regarding jgraph - why do they incorp ...

Discovering the value of a variable within an object using JavaScript

Here is the code snippet I am working with: for (var i = 0; i<ke.length; i++) { var ar = ke[i]; var temp = {ar :(n[a])}; //how to resolve a console.log(temp); } The 'temp' object is supp ...

What are the steps for importing KnockOut 4 in TypeScript?

It appears straightforward since the same code functions well in a simple JS file and provides autocompletion for the ko variable's members. Here is the TypeScript code snippet: // both of the following import lines result in: `ko` undefined // impo ...

struggling to navigate the request to a different HTML page from the controller using AngularJS

Having a situation where I need Page A to render Page B with the values entered on Page A upon submission. Page A is connected to controller A, and when the click event triggers, the Spring controller renders Page B. The problem I'm encountering is t ...

Customizing Angular routes with $routeProvider depending on user's role

I am interested in setting up routes for my angular application based on the user roles. Is there a way to accomplish this with the following code snippet: angular.module('myModule', []) .config(function($routeProvider, $http){ $rout ...

Using jQuery, identify when a key has been pressed within a three.js environment

How can I detect a keypress within a designated scene contained in a div with the id "world"? I've written the following code in an attempt to achieve this, but it doesn't seem to be working properly. Here is the code snippet: $('world&apos ...

Issue with JQuery event handlers becoming unresponsive upon resizing the window

JSBin link: http://jsbin.com/4QLDC/6 Here is the JS code snippet that I have written: var toggleContent = function (event) { $(event.target).siblings().toggle(); }; var showOrHidePanels = function () { var windowHeight = $(window).height(); v ...

choosing a section within a table cell

This seems like a simple task, but I'm encountering some difficulties $("#info-table tbody tr").each(function(){ $(this).find(".label").addClass("black"); }); .black{ font-weight:bold; } <script src="https://ajax.googleapis.com/ajax/libs/j ...

What is the process for making a custom texture map to use in ThreeJS materials?

Recently, I acquired a fbx model that utilizes a UV map to efficiently texture the model. The model is composed of a single mesh that needs to be colored using 4 quadrants as shown in the image below: https://i.sstatic.net/RR6m3.png To achieve this color ...

Using the getElementById function in javascript to modify CSS properties

Here is the setup I am working with: <div id="admin"> This element has the following style applied to it: display: none; I am attempting to change the display property when a button is pressed by defining and utilizing the following JavaScript co ...

Acquire the jQuery cookie with the power of AngularJS

I am currently utilizing jquery.cookie v1.4.1 to set a cookie in the following manner: $.cookie('userCookie', $("#user").val()); The value returned by $("#user").val() is typically something like 'username' Now, within an angular app ...

The React Js error message shows an 'Uncaught (in promise)' TypeError that prevents reading an undefined property

Struggling with passing the response from an Ajax request to another function in React. Although I am able to receive the response, I cannot pass it to { this.showBattersData(data); } where I need to render the DOM. It's clear that something is missin ...

Unable to add items to the collection in NPM with Meteor 1.3

I have encountered an issue with the imap-simple NPM package while trying to perform an insert operation. Despite following the suggestions on , I am still unable to get the insert function to work properly! Even after simplifying the code and eliminatin ...

Retrieve the session variables in a controller while making an ajax request

In my controller, I am populating certain fields with data. public string AjaxLogin() { //some code to check admin or not Session["UserName"] = "Smith"; if(type="Admin") { Session["UserRo ...

Adjusting the text color for select values within a <td> element

I have a table that is populated with data retrieved from an API. Each cell in the table contains multiple pieces of data. Below is the code used to create the table: <td class="myclass"> <?php $myvar = explode(" ", $json["data"]); ...

How can I resolve the issue of the input field added dynamically by JavaScript not appearing in the PHP $_POST variable?

I have a form nested within an HTML table. Using jQuery, I am dynamically adding input fields to the form. However, when I submit the form and check the $_POST array with var_dump(), the added fields are not showing up. Why is this happening? Below is th ...

What are the potential drawbacks of importing a namespace and a child module together? For example, using `import React, { Component } from ...`

Collaborating with some colleagues on a React project, I began by importing React and constructing my class like this: import React from 'react' Class MyComponent extends React.Component But then they suggested that I also import Component sep ...

Deactivate any days occurring prior to or following the specified dates

I need assistance restricting the user to choose dates within a specific range using react day picker. Dates outside this range should be disabled to prevent selection. Below is my DateRange component that receives date values as strings like 2022-07-15 th ...