【问题标题】:How to get global index in devexpress datagrid with ReactJS如何使用 ReactJS 在 devexpress 数据网格中获取全局索引
【发布时间】:2019-05-30 14:28:04
【问题描述】:

我在 React.js 上使用 DevExpress DataGrid。
根据this 示例,我可以导航到在特定键中不可见的特定行。
但在本例中,它使用“focusedRowKey”属性。
就我而言,我使用“focusedRowIndex”属性。

我的问题是我想按不可见的索引导航到特定行。
是否有任何接收索引而不是键的“navigateToRow”函数?
或者我可以得到全局索引,比如“getRowIndexByKey”(这个函数对我不好,如果索引在可见行之外,它返回-1)。

谢谢。

【问题讨论】:

    标签: reactjs datagrid devexpress


    【解决方案1】:

    通过在它们之间进行操作来解决它:

    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
    };
    

    然后,在组件本身上:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-05-13
      • 2012-11-14
      • 1970-01-01
      • 1970-01-01
      • 2013-06-09
      • 1970-01-01
      • 1970-01-01
      • 2018-09-27
      相关资源
      最近更新 更多