UNPKG

devextreme

Version:

JavaScript/TypeScript Component Suite for Responsive Web Development

35 lines (34 loc) • 1.17 kB
/** * DevExtreme (esm/__internal/grids/data_grid/summary/utils/get_summary_item_index.js) * Version: 26.1.6 * Build date: Fri Oct 16 2026 * * Copyright (c) 2012 - 2026 Developer Express Inc. ALL RIGHTS RESERVED * Read about DevExtreme licensing here: https://js.devexpress.com/Licensing/ */ import { isDefined } from "../../../../core/utils/m_type"; const getFullName = summaryItem => { const { summaryType: summaryType, column: column } = summaryItem; if (summaryType && column) { return `${summaryType}_${column}` } return summaryType ?? column }; export const getSummaryItemIndex = (summaryItems, name) => { if (!(null !== summaryItems && void 0 !== summaryItems && summaryItems.length) || !isDefined(name)) { return -1 } for (let index = 0; index < summaryItems.length; index += 1) { const summaryItem = summaryItems[index]; const isNameMatch = summaryItem.name === name || index === name || summaryItem.summaryType === name || summaryItem.column === name || getFullName(summaryItem) === name; if (isNameMatch) { return index } } return -1 };