Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

如何获取拖拽组件的数据 #100

Open
kanocence opened this issue Feb 20, 2024 · 6 comments
Open

如何获取拖拽组件的数据 #100

kanocence opened this issue Feb 20, 2024 · 6 comments

Comments

@kanocence
Copy link

如下图:在双列表拖拽的场景下,从左往右拖动时,只允许放置id为偶数的组件

我想使用GroupOptions中的put函数来判断,但是put函数无法获取组件原本的数据

请问使用put函数时如何获取原始列表的数据或者有什么别的处理思路吗 🤔

image

@Alfred-Skyblue
Copy link
Owner

你可以使用filter让id为奇数的不可以拖动,或者拖动的时候onMove返回false

@kanocence
Copy link
Author

你可以使用filter让id为奇数的不可以拖动,或者拖动的时候onMove返回false

上面是一个简化的场景,实际使用的场景比较复杂,使用put来判断比较合理,请问put能实现吗

@Alfred-Skyblue
Copy link
Owner

不太理解您的使用场景,您可以尝试传递函数

@kanocence
Copy link
Author

我现在的处理方式是:

  1. A列表开始拖拽
  2. 根据A列表 on-start 事件的 evt.oldIndex 从列表获取组件的数据
  3. 传递获取组件的数据
  4. 拖拽至 B列表时 put 函数判断是否允许
  5. 拖拽至C列表,D列表等 使用不同的 put 函数判断

虽然也可以使用,但是我想如果能在 put 函数触发时可以获取到当前拖拽的组件数据就能简单一些,不需要再处理获取和传递了

@moliyu
Copy link

moliyu commented Feb 20, 2024

你可以使用filter让id为奇数的不可以拖动,或者拖动的时候onMove返回false

你可以使用filter让id为奇数的不可以拖动,或者拖动的时候onMove返回false

How can I get sourceData and targetData with onMove event, I want to confirm whether it can be moved to the new item. TK

@Aaron-zon
Copy link
Contributor

put函数中有dragEl,可以通过这个获取目标数据。比如将一个唯一标识设置在拖拽元素上,说拽时通过dargEl获取这个标识,再用这个标识去查找目标数据

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants