首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >jqxwidgets jqxtree拖放问题

jqxwidgets jqxtree拖放问题
EN

Stack Overflow用户
提问于 2014-08-08 14:29:52
回答 1查看 419关注 0票数 0

我试过两棵树,它们的数据都是从json加载的。无论何时我使用json,加载,拖放都不能像预期的那样工作。事件总是取第二棵树。

我尝试从TreeA中拖动一个元素,但是它从TreeB .You中获取元素,可以看到哪个元素被从树下显示的标签中拖动。

如果TreeB中没有与TreeA相同的相应元素,则TreeA元素将被拖动。

我搞不懂。我认为与只存储第二棵树data..Any帮助的对象有关的是:)

下面是同样的小提琴演示

http://jsfiddle.net/tgb1ecLx/

代码语言:javascript
复制
function source(data) {
    var source = {
        datatype: "json",
        datafields: [{
            name: 'id'
        }, {
            name: 'parentid'
        }, {
            name: 'text'
        }, {
            name: 'value'
        }, {
            name: 'expanded'
        }],
        id: 'id',

        localdata: data
    };
    // create data adapter.
    dataAdapter = new $.jqx.dataAdapter(source);
    // perform Data Binding.
    dataAdapter.dataBind();
    // get the tree items. The first parameter is the item's id. The second parameter is the parent item's id. The 'items' parameter represents 
    // the sub items collection name. Each jqxTree item has a 'label' property, but in the JSON data, we have a 'text' field. The last parameter 
    // specifies the mapping between the 'text' and 'label' fields.  
    var records = dataAdapter.getRecordsHierarchy('id', 'parentid', 'items', [{
        name: 'text',
        map: 'label'
    }]);
    // if(tree="fact")
    $('#treeA').jqxTree({
        source: records
    });

}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-08-25 18:16:36

拖放函数的主要问题是不能区分两种树状视图。

我将所有ID值​​增加到100。(关于TreeB的数据)现在作业已经正确完成了。

我希望这能帮到你。

http://jsfiddle.net/tgb1ecLx/10/

代码语言:javascript
复制
 data = [
                    { "id": "102",
                        "parentid": "101",
                        "text": "Tree B Hot Chocolate",
                        "value": "$2.3"
                    }, {
                        "id": "103",
                        "parentid": "101",
                        "text": "Tree B Peppermint Hot Chocolate",
                        "value": "$2.3"
                    }, {
                        "id": "104",
                        "parentid": "101",
                        "text": "Tree B Salted Caramel Hot Chocolate",
                        "value": "$2.3"
                    }, {
                        "id": "105",
                        "parentid": "101",
                        "text": " Tree B White Hot Chocolate",
                        "value": "$2.3"
                    }, {
                        "text": "Tree B Chocolate Beverage",
                        "id": "101",
                        "parentid": "-1",
                        "value": "$2.3"
                }
                        ]; 
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/25205842

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档