This is a migrated thread and some comments may be shown as answers.

Filter not working with droptarget and AngularJs

7 Answers 184 Views
Drag and Drop
This is a migrated thread and some comments may be shown as answers.
Jeff
Top achievements
Rank 1
Jeff asked on 18 Aug 2014, 07:47 PM
I can't seem to get the filter working with dragdrop / angularjs.  Any help would be appreciated

I've tried:

<div class="container"  title="{{board.name}}" kendo-droptarget k-options='dropOptions' >

with these options:
function ($scope, $http) {
      $scope.dropOptions = {
          filter: ".divStatus",...
  }}

I've tried inline like:

<div class="container"  title="{{board.name}}" kendo-droptarget k-dragenter="onDragEnter" k-dragleave="onDragLeave"
            k-drop="onDrop" filter=".divStatus" >

I've tried k-filter and kendo-filter - not sure if I'm just using the wrong attribute name...

I've also tried copying this demo, http://demos.telerik.com/kendo-ui/dragdrop/angular and adding filter options to it but I can't get it to work.

I can't seem to find any documentation for this either.

Any ideas?

7 Answers, 1 is accepted

Sort by
0
Alexander Valchev
Telerik team
answered on 20 Aug 2014, 10:18 AM
Hi Nick,

You should enclose the filter with a single quotation marks in order to mark it as a string, else you will receive a JavaScript error that the option cannot be parsed.
For your convenience I prepared a small example: http://dojo.telerik.com/IHeR

Regards,
Alexander Valchev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Jeff
Top achievements
Rank 1
answered on 20 Aug 2014, 02:45 PM
Thank you for your response.

K-filter seems to be working with kendo-draggable but it's not working with "kendo-droptarget".

Here's the example in which only two of the yellow blocks should be allowed to drop in the RED block only.

http://dojo.telerik.com/IHeR/3

I added the following code:

<div id="container" kendo-droptarget k-filter="'.divTarget'"
           style="float:left;margin-left:20px;"
           k-dragenter="onDragEnter"
                    k-dragleave="onDragLeave"
           k-filter="'.divTarget'" data-k-drop="onDrop" >
        <div class="divTarget"></div>
        <div class="static"></div>
        <div class="static"></div>
        <div class="static"></div>
        <div class="divTarget"></div>
      </div>

And here's the JS which I added:

  $scope.onDragEnter = function (e) {
          console.log("onDragEnter"); 
          angular.element(e.dropTarget).addClass("green_valid");
      }

      $scope.onDragLeave = function (e) {
          console.log("onDragLeave"); 
          angular.element(e.dropTarget).removeClass("green_valid");
      }
      $scope.onDrop = function (e) {
        alert('drop allowed');
      }

Any help would be much appreciated.
0
Alexander Valchev
Telerik team
answered on 20 Aug 2014, 03:14 PM
Hello Nick,

The DropTarget does not have filter configuration option. The DropTargetArea has one.
Please see the API reference:

Regards,
Alexander Valchev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Jeff
Top achievements
Rank 1
answered on 20 Aug 2014, 07:43 PM
Bingo!  Thank you so much!
0
Pieter
Top achievements
Rank 1
answered on 11 Apr 2016, 03:20 PM

Alexander,

 

how can you use the droptargetarea in angular?

I don't seem to be able to find any documentation on this...?

 

thank you

0
Alexander Valchev
Telerik team
answered on 13 Apr 2016, 07:45 AM
Hello Pieter,

The same way you use a DropTarget. Please follow the general Kendo - AngularJS guidelines described in this help topic:


Regards,
Alexander Valchev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Pieter
Top achievements
Rank 1
answered on 13 Apr 2016, 08:13 AM

Hi Alexander,

 

thanks, I figured that out yesterday.
My issue had more to do with the config-options; it's not (very) clear what configs are possible when using angular, the docs could use some updates on that.

Anyway, thanks, it's working now!

 

Regards,
Pieter

Tags
Drag and Drop
Asked by
Jeff
Top achievements
Rank 1
Answers by
Alexander Valchev
Telerik team
Jeff
Top achievements
Rank 1
Pieter
Top achievements
Rank 1
Share this question
or