Author Topic: Drag n Drop: function to evaluate drop rows  (Read 4584 times)

mikep

  • Pro Ultimate
  • Full Member
  • *
  • Posts: 163
    • View Profile
Drag n Drop: function to evaluate drop rows
« on: September 13, 2019, 01:05:34 am »
I need to disallow rows from being dropped into my main grid, based on conditions in the source grid column. If the 1st column in the dropped row from the source grid is not checked, I don't want the row added.

How would I update the below function to do this.


                drop: function (evt, uiDrop) {



                    //only add if the source column is checked
                    this.addNodes([node], isNaN(rowIndx) ? null : rowIndx);
                }


paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Re: Drag n Drop: function to evaluate drop rows
« Reply #1 on: September 13, 2019, 12:22:46 pm »
There is no need to override dropModel.drop callback.

dragModel.isDraggable and dropModel.isDroppable callbacks can be used to set up conditional rules for selective drag & drop of rows.

https://paramquery.com/pro/api#option-dragModel

mikep

  • Pro Ultimate
  • Full Member
  • *
  • Posts: 163
    • View Profile
Re: Drag n Drop: function to evaluate drop rows
« Reply #2 on: September 13, 2019, 05:04:26 pm »
Thanks, that helps. Are there any examples demonstrating this, that I can work from?

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Re: Drag n Drop: function to evaluate drop rows
« Reply #3 on: September 13, 2019, 06:32:54 pm »
This example demonstrates usage of dragModel.isDraggable and dropModel.isDroppable callbacks

https://paramquery.com/pro/demos/dnd_tree

mikep

  • Pro Ultimate
  • Full Member
  • *
  • Posts: 163
    • View Profile
Re: Drag n Drop: function to evaluate drop rows
« Reply #4 on: September 30, 2019, 06:45:21 pm »
Thank you.

Another question. When a row is dragged onto another grid, is there a way to know which column the row is dropped onto in the target grid?

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Re: Drag n Drop: function to evaluate drop rows
« Reply #5 on: September 30, 2019, 07:05:07 pm »
Yes

1. When a row is hovered onto another row, column information of the underlying row can be obtained from column specific fields ( $cell, colIndx ) in dropModel.isDroppable callback.

2. When a row is actually dropped onto another row after isDroppable check, column information of the underlying row can be obtained from column specific fields ( $cell, colIndx ) in dropModel.drop callback.

https://paramquery.com/pro/api#option-dropModel

mikep

  • Pro Ultimate
  • Full Member
  • *
  • Posts: 163
    • View Profile
Re: Drag n Drop: function to evaluate drop rows
« Reply #6 on: December 05, 2019, 08:46:54 pm »
How can I prevent the dragged item from being removed from it's source grid?
https://jsfiddle.net/gr9mq0es/

I've seen your code example of this, but I don't understand your code which implements this. so wanted to provide a more basic scenario.

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Re: Drag n Drop: function to evaluate drop rows
« Reply #7 on: December 06, 2019, 09:55:29 pm »
Please use empty implementation of dragModel.beforeDrop callback.

Code: [Select]
                dragModel: {
                    on: true,
                    clsDnD: 'dnd3',
                    diHelper: ['proj'],
                    beforeDrop: function(){
                   
                    }
                },

https://jsfiddle.net/quoxkzvn/

https://paramquery.com/pro/api#option-dragModel