Exemplo n.º 1
0
        public GridColl(GridView gv, IEntityCollection eColl,
                        BaseEntity Entity)
        {
            ListCols   = new Dictionary <int, xCol>();
            this.gv    = gv;
            this.eColl = eColl;
            Type ChildType = null;

            if (gv.LevelName.Length > 0)
            {
                foreach (GridColumn gcol in gv.Columns)
                {
                    RepositoryItemLookUpEditBase rle = gcol.ColumnEdit
                                                       as RepositoryItemLookUpEditBase;
                    if (rle != null)
                    {
                        gcol.SortMode   = ColumnSortMode.DisplayText;
                        gcol.FilterMode = ColumnFilterMode.DisplayText;
                        ListCols.Add(gcol.AbsoluteIndex,
                                     new xCol(gcol, rle, null, null));
                    }
                }
                return;
            }
            else if (eColl == null)
            {
                TableDef tdEntity  = MetaData.GetTableDef(Entity.GetType());
                string   ChildName = ((BindingSource)gv.GridControl.DataSource).DataMember;

                foreach (EntityCollDef ecd in tdEntity.ChildEntities)
                {
                    if (ecd.FieldName == ChildName)
                    {
                        ChildType = ecd.GetChildType();
                        break;
                    }
                }
            }
            else
            {
                ChildType = eColl.GetChildType();
            }

            gv.RowUpdated += new RowObjectEventHandler(gv_RowUpdated);

            td = MetaData.GetTableDef(ChildType);
            Type tp = Entity.GetType();

            foreach (GridColumn gcol in gv.Columns)
            {
                RepositoryItemLookUpEditBase rle = gcol.ColumnEdit
                                                   as RepositoryItemLookUpEditBase;
                if (rle != null)
                {
                    gcol.SortMode   = ColumnSortMode.DisplayText;
                    gcol.FilterMode = ColumnFilterMode.DisplayText;
                    ListCols.Add(gcol.AbsoluteIndex,
                                 new xCol(gcol, rle, td, tp));
                }
            }
            gv.CustomColumnDisplayText     += new CustomColumnDisplayTextEventHandler(gv_CustomColumnDisplayText);
            gv.CustomRowCellEditForEditing += new CustomRowCellEditEventHandler(gv_CustomRowCellEditForEditing);
        }