2016-08-10 51 views
1

我有一個虛擬啓用的劍道組合框,我想回顧選定的項目,因爲我需要更多的信息後。劍道組合框回顧虛擬選定的項目

當我在一些虛擬加載後選擇一個項目時,我得到了undefined。

這是我的代碼

$scope.select_item_options = { 
     dataValueField: "id", 
     dataTextField: "description_nhl", 
     template: "#= description #", 
     virtual: true, 
     filter: "contains", 
     change: function(e) { 
      var selected_index = this.selectedIndex; 
      if (selected_index < 0) { 
       delete $scope.work_item.item_id; 
      } else { 
       var item = this.dataItem(this.select()); 
       console.log(item); 
       console.log(this.dataItem(selected_index)); 
       // undefined here 
      } 
      $scope.$apply(); 
     }, 
     dataSource: new kendo.data.DataSource({ 
      transport: { 
       read: { 
        type: "GET", 
        url: APP_CONFIG.api.base_url + "/items/itemTypes/AC", 
        contentType: "application/json; charset=utf-8", 
        dataType: "json", 
        beforeSend: function(xhr) { 
         xhr.setRequestHeader('Authorization', storageService.getValue('auth_token')); 
        }, 
        complete: function(result, status) { 
         if (result.status !== 200 || !result.responseJSON.fn.result.done) { 
          return httpService.callbackOnError(result.responseJSON, result.status); 
         } 
        } 
       } 
      }, 
      schema: { 
       data: 'data', 
       total: function(data) { 
        return data.dataCount; 
       } 
      }, 
      serverPaging: true, 
      serverSorting: true, 
      serverFiltering: true, 
      pageSize: 5, 
      sort: {field: "description", dir: "asc"} 
     }) 
    }; 
+0

我用this.dataItem()沒有參數,似乎是工作,我在測試 – Davide

回答

1

解決不斷變化的

var item = this.dataItem(this.select());

var item = this.dataItem();