Dojo拖放:如何检索项目的顺序? [英] Dojo Drag and drop: how to retrieve order of items?

查看:90
本文介绍了Dojo拖放:如何检索项目的顺序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个Source对象,并通过创建者进行配置,以便为用户提供一组数据,以便用户按需进行排序。这一切都很好。但是,一旦用户重新排序,我不知道如何检索数据。 getAllNodes返回dom节点;我需要原始的数据对象。

I've created a Source object and configured (via the creator) so that it renders a set of data for my users to order as they wish. This is all working fine. However, I cannot figure out how to retrieve the data once the user has re-ordered it. getAllNodes returns the dom nodes; I need the original data objects.

推荐答案

这真的很简单—只需使用 getItem()(在官方文档中描述)。这样的事情会给你所有的数据元素顺序:

It is really easy — just use getItem() (described in the official documentation). Something like that will give you all data elements in order:

var source = new dojo.dnd.Source(...);
...
var orderedDataItems = source.getAllNodes().map(function(node){
        return source.getItem(node.id).data;
    });

就是这样。

这篇关于Dojo拖放:如何检索项目的顺序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆