2016-09-23 139 views
1

我使用AG-网后:如何不重置过滤器的刷新按钮被点击AG-电网

tutorial.js:

(function() { 
var columnDefs = [ 
    {headerName: "Athlete", field: "athlete", width: 150, filter: 'set'}, 
    {headerName: "Age", field: "age", width: 90, cellRendered: timestampCellRenderer} 

]; 

function timestampCellRenderer(params) { 
    return params.value + ' <span style="font-size: 10px; color: grey;">' + new Date().getTime() + '</span>'; 
} 


function onRefreshAll() { 
    gridOptions.api.refreshView(); 
} 
var gridOptions = { 
    columnDefs: columnDefs, 
    rowData: null, 
    enableSorting: true, 
    enableFilter: true, 
    enableColResize: true 
}; 


// setup the grid after the page has finished loading 
document.addEventListener('DOMContentLoaded', function() { 
    var gridDiv = document.querySelector('#myGrid1'); 
    new agGrid.Grid(gridDiv, gridOptions); 

    // do http request to get our sample data - not using any framework to keep the example self contained. 
    // you will probably use a framework like JQuery, Angular or something else to do your HTTP calls. 
    var httpRequest = new XMLHttpRequest(); 
    httpRequest.open('GET', '../dist/olympicWinners.json'); 
    httpRequest.send(); 
    httpRequest.onreadystatechange = function() { 
     if (httpRequest.readyState == 4 && httpRequest.status == 200) { 
      var httpResult = JSON.parse(httpRequest.responseText); 
      gridOptions.api.setRowData(httpResult); 
      gridOptions.api.sizeColumnsToFit(); 
      console.log(httpResult); 
     } 
    }; 
}); 
window.onRefreshAll = onRefreshAll; 
})() 

的index.html:

<html> 
<head> 
    <!-- you don't need ignore=notused in your code, this is just here to trick the cache --> 
    <script src="../dist/ag-grid-enterprise.js?ignore=notused31"></script> 
    <script src="tutorial1.js"></script> 
    <script src="tutorial.js"></script> 

</head> 
<body> 
<div id="myGrid1" class="ag-fresh" style="height: 400px;"></div> 
<div> 
    <span style="padding-bottom: 4px; display: inline-block;"> 
     <button onclick="onRefreshAll()">Ireland & UK</button> 


    </span> 
    <br/> 

</div> 

<div id="myGrid" class="ag-fresh" style="height: 400px;"></div> 

</body> 
</html> 

所以,每当点击“刷新”按钮时,刷新并重置在列上完成的所有排序。只要刷新按钮被点击,只有数据被更新并且过滤器保持不变,排序是否可能重置?

回答

1

我向AG-Grid团队询问了同样的问题,请查看delta-row-data模式。