Exemple #1
0
        /// <summary>
        /// 得到ChildColumns中的集合,用,号分开
        /// Get ChildSequence no respect to the GridColumns for ChildColumns in StackedHeaderRow
        /// </summary>
        /// <param name="column"></param>
        /// <param name="rowIndex"></param>
        /// <returns></returns>
        /// <remarks></remarks>
        public static List <int> GetChildSequence(this SfDataGrid sfgrid, StackedColumn column, int rowIndex)
        {
            List <int> childSequencNo = new List <int>();

            if (column != null)
            {
                var childColumns = column.ChildColumns.Split(',');
                foreach (var child in childColumns)
                {
                    bool bFound         = false;
                    var  currentColumns = sfgrid.Columns;
                    for (int i = 0; i < currentColumns.Count; ++i)
                    {
                        if (currentColumns[i].MappingName == child)
                        {
                            childSequencNo.Add(i);
                            bFound = true;
                            break;
                        }
                    }
                    if (!bFound)
                    {
                        var childSubSequence = sfgrid.GetChildSequence(sfgrid.GetStackedColumn(child, rowIndex + 1), rowIndex);
                        childSequencNo = childSequencNo.Union(childSubSequence).ToList();
                    }
                }
                return(childSequencNo);
            }
            return(childSequencNo);
        }
Exemple #2
0
        /// <summary>
        /// Gets StackedColumn corresponding to the given name and index
        /// </summary>
        /// <param name="columnName"></param>
        /// <param name="rowIndex"></param>
        /// <returns></returns>
        /// <remarks></remarks>
        private static StackedColumn GetStackedColumn(this SfDataGrid sfgrid, string columnName, int rowIndex)
        {
            StackedHeaderRow header = null;
            StackedColumn    column = null;

            if (rowIndex >= sfgrid.StackedHeaderRows.Count)
            {
                return(null);
            }
            header = sfgrid.StackedHeaderRows[rowIndex];
            while (true)
            {
                column = header.StackedColumns.FirstOrDefault(child => child.HeaderText == columnName);
                if (column == null)
                {
                    column = sfgrid.GetStackedColumn(columnName, rowIndex + 1);
                }
                return(column);
            }
        }