2016-04-28 16 views
2

別のコントローラからモーダルポップアップが開きます。モーダルポップアップを閉じると、私は何かを行い、データをUIグリッドに入力する別のコントローラに転送し、$scope.searchResultsGridOptionsにバインドします。UIグリッドリフレッシュ(角度単位)

だから私のABCCtrl.jsファイルに:

モーダルの閉鎖で、私は:DEFCtrl.js

$("#iConfirmationModal").on('hidden.bs.modal', function() { 
    $state.go('transaction.search.results', {}); 
    //I close all the modals 
    $uibModalStack.dismissAll(); 
    //I get the stored search criteria 
    var searchResultsParam = TransactionDataServices.getSavedSearchParams(); 


    //Using them I hit the web service again and get the data to reload the UI Grid 
    TransactionServices.getTransactionAdvSearchResults(searchResultsParam).then(function (result) { 

      //I got the result 
      console.log(result); 
      /Now I want to reload the grid with this data , but the grid scope object which binds to this , is in separate controller 
      searchResultsGridOptions.data = result; 
     }); 
    }); 

を私は

getSearchResultsGridLayout: function (gridOptions, uiGridConstants, datas) { 
     gridOptions.multiSelect = false; 
     // gridOptions.data.length = 0; 
     // gridOptions.data = ''; 
     gridOptions.data = datas; 
     console.log("Grid Data "); 
     console.log(datas); 
     console.log(gridOptions.data); 
     angular.element(document.getElementsByClassName('grid')[0]).css('height', '0px'); 
     // console.log(datas.length); 
     return gridOptions; 
    } 

しかし、どのように希望を持っています私はモーダルが閉じたときにのみデータを変更しますか?

グリッドをリフレッシュしないでください。

あるいは、

はモーダルの閉鎖、代わりに単にバック $state.for()を使用して、前の未リフレッシュデータが表示状態に戻るには、私は更新されたデータを見ることができる方法はありますか?

答えて

0

こんにちは、 "ABCCtrl"コントローラで "TransactionServices.getTransactionAdvSearchResults()"を呼び出す必要はありませんが、 "DEFCtrl"コントローラで呼び出す必要があると思います。

"ABCCtrl"で抽出された "searchResultsParam"を "DEFCtrl"に渡す方法を見つける必要があります。

ui-router state parametersを使用できます。あなたはこのように、 "transaction.search.results" 状態でパラメータを指定することができます。DEFCtrl」で、その後

$("#iConfirmationModal").on('hidden.bs.modal', function() { 
    //I close all the modals 
    $uibModalStack.dismissAll(); 
    //I get the stored search criteria 
    var searchResultsParam = TransactionDataServices.getSavedSearchParams(); 
    $state.go('transaction.search.results', {searchResultsParam: searchResultsParam}); 

.state('transaction.search.results', { 
    ... 
    params: { 
     searchResultsParam: null 
    } 
    ... 
}) 

そして "ABCCtrl" で

状態にそれを渡しますそれを読んで、 "TransactionServices.getTransactionAdvSearchResults()"メソッドを呼び出すことができます。

関連する問題