/// <summary>
        /// Resolves the row index corresponding to the specified record.
        /// </summary>
        /// <param name="dataGrid">
        /// The SfDataGrid.
        /// </param>
        /// <param name="recordItem">
        /// Specifies the record to get its corresponding row index.
        /// </param>
        /// <returns>
        /// Returns the row index of the specified record.
        /// </returns>
        public static int ResolveToRowIndex(this SfDataGrid dataGrid, object recordItem)
        {
            if (dataGrid.GetRecordsCount(false) == 0)
            {
                return(-1);
            }

            // Need to get the record or record index from DisplayElements when the Source is IQueryable. Since we will keep null record entries View.Records. Entries will be kept in Group.Records alone.
            var recordIndex = dataGrid.GridModel.HasGroup && dataGrid.isIQueryable ?
                              dataGrid.View.TopLevelGroup.DisplayElements.IndexOf(recordItem) :
                              dataGrid.View.Records.IndexOfRecord(recordItem);

            if (recordIndex < 0)
            {
                return(-1);
            }

            if (!dataGrid.GridModel.HasGroup)
            {
                if (dataGrid.DetailsViewManager.HasDetailsView)
                {
                    return((recordIndex * (dataGrid.DetailsViewDefinition.Count + 1)) + dataGrid.ResolveStartIndexBasedOnPosition());
                }
                else
                {
                    return(recordIndex + dataGrid.ResolveStartIndexBasedOnPosition());
                }
            }
            else
            {
                var record = dataGrid.isIQueryable ? dataGrid.View.TopLevelGroup.DisplayElements.GetItem(recordItem):
                             dataGrid.View.Records.GetRecord(recordItem);
                if (record.Parent != null)
                {
                    var grpRecordIndex = dataGrid.View.TopLevelGroup.DisplayElements.IndexOf(record);
                    if (grpRecordIndex > -1)
                    {
                        var groupPos = grpRecordIndex + dataGrid.ResolveStartIndexBasedOnPosition();
                        return(groupPos);
                    }
                }
            }
            return(-1);
        }
        /// <summary>
        /// Resolves the row index corresponding to the specified node entry.
        /// </summary>
        /// <param name="dataGrid">
        /// The SfDataGrid.
        /// </param>
        /// <param name="nodeEntry">
        /// Specifies the node entry to get its corresponding row index.
        /// </param>
        /// <returns>
        /// Returns the row index of the specified node entry.
        /// </returns>
        public static int ResolveToRowIndex(this SfDataGrid DataGrid, NodeEntry nodeEntry)
        {
            if (nodeEntry == null || DataGrid.GetRecordsCount(false) == 0)
            {
                return(-1);
            }

            if (!DataGrid.GridModel.HasGroup)
            {
                //The Below Condition "(NestedRecordentry).nodeEntry.Parent != null" is added while the parent  becomes null when we call the ExpandAll().
                //So here we have return the rowindex as -1 when the parent is null.
                var rowIndex = nodeEntry is NestedRecordEntry ? (((NestedRecordEntry)nodeEntry).Parent != null ? ResolveToRowIndex(DataGrid, (((NestedRecordEntry)nodeEntry).Parent as RecordEntry).Data) : -1) : ResolveToRowIndex(DataGrid, (nodeEntry as RecordEntry).Data);
                if (rowIndex > -1)
                {
                    if (nodeEntry is NestedRecordEntry)
                    {
                        var parentRecordEntry = (nodeEntry as NestedRecordEntry).Parent as RecordEntry;
                        var Key   = parentRecordEntry.ChildViews.Where(kvp => kvp.Value == nodeEntry).Select(kvp => kvp.Key).FirstOrDefault();
                        int index = parentRecordEntry.ChildViews.Keys.ToList().IndexOf(Key);
                        return(rowIndex + index + 1);
                    }
                    else
                    {
                        return(rowIndex);
                    }
                }
            }
            else
            {
                var grpRecordIndex = DataGrid.View.TopLevelGroup.DisplayElements.IndexOf(nodeEntry);
                if (grpRecordIndex > -1)
                {
                    var groupPos = grpRecordIndex + DataGrid.ResolveStartIndexBasedOnPosition();
                    return(groupPos);
                }
            }
            return(-1);
        }