简体   繁体   中英

How to get global index in devexpress datagrid with ReactJS

I'm working with DevExpress DataGrid on React.js.
According to this example, I can navigate to specific row that not visible within a specific key.
But in this example, it use the "focusedRowKey" property.
In my case, I use the "focusedRowIndex" property.

My problem is that I want to navigate to specific row by index that is not visible.
Is there any "navigateToRow" function that receive index, and not key?
Or can I get the global index, like "getRowIndexByKey" (this function not good for me, if the index is outside the visible rows, it return -1).

Thanks.

Solved it by manipulating between them:

let value = null;

// eslint-disable-next-line default-case
switch (fieldType) {
  case 'focusedRowIndex':
    value = eventIndex;
    break;
  case 'focusedRowKey':
    value = eventId;
    break;
}

const obj = {
  [fieldType]: value
};

And then, on the component itself:

        <DataGrid
          id='grid-container'
          dataSource={events}
          keyExpr='_Id'
          showBorders={true}
          focusedRowEnabled={true}
          {...obj}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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