2013-10-10 1 views
2

initially_open 아래 라인 jstree를 사용하는 동안은, 링크 http://code.google.com/p/jstree/issues/detail?id=294jstree initially_select 코드의

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

에 언급 된 예외를 throw, 어떤 문제없이 작동합니다.

"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을 형성하고 그 위에 하드 코딩 된 값과 동일하다. 그러나 여전히 문제는 해결되지 않습니다. 제발 제안 해주세요. UR 참조

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

답변

0

버그가 quotedAndCommaSeparated가리스트되지 않는 것입니다, 그냥 문자열입니다.

당신은 단순히 그럼 당신이 직접하는 데 도움이 jstree 초기화

"ui" : { "initially_select" : [ initiallySelect ] }, 

희망이를 사용할 수있는 initiallySelect 목록

initiallySelect.push(companyId + ""); 

에 숫자 대신 문자열을 추가해야합니다.