简体   繁体   English

sortChanged 事件在带有反应的 ag-grid 中不起作用

[英]sortChanged event not working in ag-grid with react

I am using ag-grid with react;我正在使用 ag-grid 和 react; it has an event它有一个事件

  sortChanged={sortChanged}

According to this documentation http://54.222.217.254/javascript-grid-events/#sort-filter根据此文档http://54.222.217.254/javascript-grid-events/#sort-filter

But in my case it doesn't get called, I am not sure why.但就我而言,它没有被调用,我不确定为什么。

What i can see from this Link is that it is working in angular.我从这个链接可以看到它在 angular 中工作。

I tried to follow different syntax and went through its complete documentation but no luck.我尝试遵循不同的语法并浏览了它的完整文档,但没有成功。

This is my forged punker where i just want the alert hi just to know that user clicked to sort: https://plnkr.co/edit/48MYV18mpAAuK27L?preview这是我伪造的 punker,我只想知道用户点击了排序: https://plnkr.co/edit/48MYV18mpAAuK27L?preview

I am trying like this:我正在尝试这样:

  <AgGridReact
    defaultColDef={{ sortable: true }}
    onGridReady={onGridReady}
    rowData={rowData}
    sortChanged={sortChanged}
  >

and using it like this:并像这样使用它:

 const sortChanged = (e) => {
    alert("hi")
    console.log(e)
    }

Try one of these:尝试其中之一:

const onSortChanged=(e: AgGridEvent)=> {
  e.api.refreshCells();
}

or或者

const onSortChanged=(e: AgGridEvent)=> {
   e.api.redrawRows();
 }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM