2016-12-09 10 views
0

검도 각 차트와 다중 선택을 사용하고 있습니다. 지금은 같은 API를 두 번 호출하여 데이터를로드합니다. 동일한 API 호출에서 여러 스키마를 정의 할 수있는 방법이 있습니까? 내 데이터는 내가 그리드 "은 NameList는"하나의 API 호출에 다중 선택에 추가 할에 "목록"을 추가 할검도 차트 및 검도 멀티 셀렉트에 동일한 데이터 소스를 사용하려면 어떻게해야합니까?

{ 
    "List": [ 
    { 
     "Name": "xyz", 
     "Activation": "2016-12-08",  
     "End": "2016-12-09", 
     "Run": "45", 
     "Status": "FAILURE", 
     "color": "red" 
    }, 
    { 
     "Name": "wqe", 
     "Activation": "2016-12-07",   
     "End": "2016-12-08", 
     "Run": "46", 
     "Status": "FAILURE", 
     "color": "red" 
    } 
    ], 
    "NameList": [ 
    { 
     "Name": "joo" 
    }, 
    { 
     "Name": "foo" 
    }, 
    { 
     "Name": "too" 
    } 
    ] 
} 

을 다음과 같이한다.

현재 내가 API를 호출하는 다음 코드를 사용하고

function getDataSource(requestUrl) { 

    var dataSource = { 
     transport: { 
      read: requestUrl, 
      dataType: "json" 
     }, 
     schema: { 
      data: "List", 
      total: function (response) { 
       return response.StatisticList.length; 
      }, 
      model: { 
       fields: { 
        Name: { type: "string" }, 
        Activation: { type: "date" }, 
        End: { type: "date" }, 
        Run: { type: "number" }, 
        Status: { type: "string" },       
        color: { type: "string" } 
       } 
      } 
     }, 
     sort: { field: "ActivationTime", dir: "desc" }, 
     pageSize: common.Grid.pageSize 
    }; 
    return dataSource; 
} 

function getMultiSelectDataSource(requestUrl) { 

    var dataSource = { 
     transport: { 
      read: requestUrl, 
      dataType: "json" 
     }, 
     schema: { 
      data: "NameList", 
      model: { 
       fields: { 
        Name1: { type: "string" } 
       } 

      } 
     } 
    }; 
    return dataSource; 
} 

답변

1

당신이 수동으로 직접 요청을 할 경우, 시나리오에서 하나 개의 요청으로 두 위젯의 데이터 바인딩을 달성하고, local (custom) transport 또는 정적을 사용할 수 있습니다 dataSource.data 차트 및 다중 선택의 데이터 소스에 지정.