2012-06-20 54 views
0

當LoadOnDemand設置爲true時,我需要一些幫助來使用igTree。 我有一個WCF REST服務,它將數據填充到igTree中。Infragistics jQuery Tree

請找到示例代碼..

$.ajax(
      { 
       type: "GET", 
       url: "AssessmentProcWCFService.svc/GetAllEntities", 
       contentType: "application/json; charset=utf-8", 
       dataType: 'json', 
       data: '{}', 
       cache: false, 
       success: OnGetAllEntitiesSuccess, 
       error: OnGetAllEntitiesFailure 
      }); 

================================ ==================

function OnGetAllEntitiesSuccess(categoryList) { 
    $("#APTreeView").igTree({ 
        animationDuration: 0, 
        dataSourceType: 'json', 
        dataSource: categoryList.d, 
        initialExpandDepth: false, 
        loadOnDemand: true, 
        dataSourceUrl: "AssessmentProcWCFService.svc/GetAllCategories?EntityID=primaryKey:id", 
        bindings: { 
         textKey: 'text', 
         valueKey: 'id', 
         primaryKey: 'id', 
         expanded: 'expanded', 
         childDataProperty: 'children' 
        } 
       }); 
      } 

========================= ================================

問題: -

  1. 當樹的任何節點擴展時,如何將所選節點ID發送到服務? 我在上面的例子中發送它的方式,當我在服務「公共列表GetAllCategories()」 「字符串entityID = HttpContext.Current.Request.QueryString [」EntityID「];」 我得到實體ID爲空。

  2. 如果LoadOnDemand爲true,那麼當任何節點得到展開時樹如何呈現?

請幫助我,我花了很多時間在它。

回答

1

基本上你可以編碼任何你到服務提出的要求,如:

以下是默認的請求參數解釋:http://www.infragistics.com/community/forums/t/65356.aspx

這裏是你如何可以添加一個請求參數:

function OnGetAllEntitiesSuccess(categoryList) { 
    $("#APTreeView").igTree({ 
        animationDuration: 0, 
        dataSourceType: 'json', 
        dataSource: categoryList.d, 
        initialExpandDepth: false, 
        loadOnDemand: true, 
        dataSourceUrl: "AssessmentProcWCFService.svc/GetAllCategories?EntityID=primaryKey:id", 
        bindings: { 
         textKey: 'text', 
         valueKey: 'id', 
         primaryKey: 'id', 
         expanded: 'expanded', 
         childDataProperty: 'children' 
        }, 
        nodePopulating: function (event, ui) { 
         var node = '&SelectedNodeID=' + $("#APTreeView").igTree('selectedNode').element.attr('data-value'), 
          myNewUrl = 'AssessmentProcWCFService.svc/GetAllCategories?EntityID=primaryKey:id' + node; 
         $('#myTree').igTree('option', 'dataSourceUrl', myNewUrl); 
        } 
       }); 
      }