【问题标题】:jqxwidgets jqxtree drag drop issuejqwidgets jqxtree拖放问题
【发布时间】:2014-08-08 14:29:52
【问题描述】:

我尝试了两棵从 json 加载数据的树。每当我使用 json 加载拖放时,都无法按预期工作。该事件始终采用第二棵树。

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

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

我想不通。我认为有些事情与只存储第二个树数据的对象有关。任何帮助将不胜感激:)

下面是同样的小提琴演示

http://jsfiddle.net/tgb1ecLx/

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
    });

}

【问题讨论】:

    标签: jquery jqxwidgets


    【解决方案1】:

    拖放功能的主要问题是无法区分两个树视图。

    我把所有的ID值都增加到了一百。 (在 TreeB 的数据上)现在作业已正确完成。

    我希望这会有所帮助。

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

     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"
                    }
                            ]; 
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-03-09
      • 2011-06-27
      • 2023-04-10
      • 2015-08-27
      • 2013-10-19
      • 1970-01-01
      相关资源
      最近更新 更多