private static void SetQuickSortItems(XmlElement xe, GroupSchema gs, bool isColumnSort)
        {
            if (xe == null)
            {
                return;
            }
            QuickSortSchema sortSchema = new QuickSortSchema();

            foreach (XmlElement n in xe.ChildNodes)
            {
                string     key      = n.GetAttribute(GroupSchemas._xmlKeyName);
                string     order    = n.GetAttribute(GroupSchemas._xmlKeyOrder);
                int        level    = Convert.ToInt32(n.GetAttribute(GroupSchemas._xmlKeySortLevel));
                int        priority = Convert.ToInt32(n.GetAttribute(GroupSchemas._xmlKeyPriority));
                SortOption so       = new SortOption();
                so.SortDirection = (SortDirection)Enum.Parse(typeof(SortDirection), order);
                so.Priority      = priority;
                sortSchema.Add(key, so, level);
            }
            if (isColumnSort)
            {
                gs.ColumnSortSchema = sortSchema;
            }
            else
            {
                gs.SortSchema = sortSchema;
            }
        }
Ejemplo n.º 2
0
        public object Clone()
        {
            QuickSortSchema sort = new QuickSortSchema();

            foreach (QuickSortItem item in this.QuickSortItems)
            {
                sort.QuickSortItems.Add(new QuickSortItem(item.Level, item.Name, item.SortDirection, item.Priority));
            }
            return(sort);
        }
        private void InitSort(GroupSchema gs)
        {
            QuickSortSchema sortSchema = new QuickSortSchema();
            int             Priority   = 1;

            if (gs.SchemaItems.Count < 1)
            {
                return;
            }
            if (gs.SchemaItems.Count < 3)
            {
                foreach (GroupSchemaItem group in gs.SchemaItems)
                {
                    foreach (string name in group.Items)
                    {
                        QuickSortItem item = new QuickSortItem();
                        item.Level    = group.Level;
                        item.Priority = Priority;
                        Priority++;
                        item.Name          = name;
                        item.SortDirection = SortDirection.Descend;
                        sortSchema.QuickSortItems.Add(item);
                    }
                }
            }
            else
            {
                gs.SortSchema = sortSchema;
                GroupSchemaItem column = gs.SchemaItems[1];
                foreach (string name in column.Items)
                {
                    QuickSortItem item = new QuickSortItem();
                    item.Level    = 2;
                    item.Priority = Priority;
                    Priority++;
                    item.Name          = name;
                    item.SortDirection = SortDirection.Descend;
                    sortSchema.QuickSortItems.Add(item);
                }
                gs.ColumnSortSchema = sortSchema;
            }
        }