2

以下のコード行は、jstree を使用しているときに、リンク http://code.google.com/p/jstree/issues/detail?id=294に記載されている例外をスローします。

**"ui" : { "initially_select" : [ quotedAndCommaSeparated ] }**
**"core" : { "animation" : 0, "initially_open" : [ quotedAndCommaSeparated ] }** 

以下のようにハードコードされた値を使用すると、問題なく動作します。

"ui" : { "initially_select" : ['3381','7472','7473','7474','7247','7248','7249','3273','3272'] }

"core" : { "animation" : 0, "initially_open" : [ '3381','7472','7473','7474','7247','7248','7249','3273','3272' ] }

配列から quotedAndCommaSeparated を作成しましたが、上記のハードコードされた値と同じです。しかし、まだ問題は解決していません。提案してください。

quotedAndCommaSeparated = '3381','7472','7473','7474','7247','7248','7249','3273','3272'

参照用の完全なコード:

スクリプトの場合:

static.jstree.com/v.1.0pre/jquery.jstree.js
static.jstree.com/v.1.0pre/_docs/syntax/!script.js

function BindTreeView(nodeToHighlight, isInitialLoad)
    {    
        var initiallySelect = [];
        var searchOption = 0;
        if($('#rbobtnSelectedLevelAndBelowRadio:checked').val() == 'Selected Level and Below')
            searchOption = 1;
        else if($('#rdobtnCurrentOrganization:checked').val() == 'Current Organization')
            searchOption = 2;

        if(searchOption == 0)
            initiallySelect.push(nodeToHighlight);
        else if (searchOption == 1 || searchOption == 2)
        {
            var grid = $("#SearchResultJQGrid");
            ids = grid.jqGrid("getDataIDs");
            if(ids && ids.length > 0)
            {
                for(var iRow = 1; iRow < ids.length; iRow++)
                {
                    var dataRow = $("#SearchResultJQGrid").getRowData(iRow);
                    var companyId = dataRow.CompanyID;
                    initiallySelect.push(companyId);
                }
            }   
        }

        var quotedAndCommaSeparated = "'" + initiallySelect.join("','") + "'";
        var urlRef = '/Group/GetDataForTreeView';

        $('#TreeView').jstree({
                                "json_data" : {  
                                    "ajax" : {
                                    "cache": false,  
                                    "url": function (node) {
                                                var nodeId = "";
                                                if (node == -1)
                                                    url = urlRef;
                                                return url;
                                            },                                          
                                    "data" : function (n) {  
                                                return { id : n.attr ? n.attr("id") : 0 };   
                                        }
                                    }  
                                }, 
                                "ui" : { "initially_select" : [ quotedAndCommaSeparated ] },
                                "core" : { "animation" : 0, "initially_open" : [ quotedAndCommaSeparated ] }, 
                                "themes": {
                                            "theme": "classic",
                                            "dots": true,
                                            "icons": false
                                          },
                                "plugins" : [ "themes", "json_data", "ui", "core" ]  
                                }).bind("select_node.jstree", function (event, data)                  {                                                                                                                                          if(isInitialLoad == true)        
                                                    isInitialLoad = false;
                                                else
                                                    BindGridView('CV', data.rslt.obj.attr("name"), data.rslt.obj.attr("id"), isInitialLoad);
        });     
    }
4

1 に答える 1