コード例 #1
0
ファイル: XtraGrid.cs プロジェクト: labeuze/source
 public void SetGridOption()
 {
     string sOption = gGridDefinition.zAttribValue("Option");
     gGridOption = new XtraGridOption(sOption);
 }
コード例 #2
0
ファイル: XtraGrid.cs プロジェクト: labeuze/source
        public void SetGridDataSource()
        {
            //GridSetDataSource(gGridMaster, dt, xe, con, dataList, option);
            //gdtMaster.RowDeleting += new DataRowChangeEventHandler(DataTableMaster_RowDeleting);
            //gsMasterName = sDataName;
            //LoadMasterParameters();

            //if (gbTrace) cTrace.StartNestedLevel("SetGridDataSource");

            //if (gbTrace) cTrace.StartNestedLevel("EndEvent");
            //if (grid.Tag is FormGridEvent)
            //    ((FormGridEvent)grid.Tag).End();
            //if (gbTrace) cTrace.StopNestedLevel("EndEvent");

            gGridView.CollapseAllDetails();
            //GridClearDataSource(grid);
            if (gGridOption.MasterViewMode) XtraGridTools.GridCreateDetailViews(gGridControl, gdt);

            //if (gbTrace) cTrace.StartNestedLevel("SetDataSource");
            gGridControl.DataSource = gdt;
            gGridControl.ForceInitialize();
            //if (gbTrace) cTrace.StopNestedLevel("SetDataSource");

            XtraGridTools.SetNavigatorOption(gGridControl, gGridOption);
            //GridSetViewOption((GridView)grid.MainView, xe, dt, con, dataList, option);
            GridSetViewOption(gGridView, gGridOption, gGridDefinition, gdt);

            //grid.Leave += new EventHandler(GridControl_Leave);

            if (gGridDefinition != null && gGridOption.MasterViewMode)
            {
                IEnumerator<XElement> xeDetailEnum = gGridDefinition.Elements("def").GetEnumerator();
                foreach (DataRelation r in gdt.ChildRelations)
                {
                    if (!xeDetailEnum.MoveNext()) break;
                    XElement xeDetailDefinition = xeDetailEnum.Current;
                    string sRelation = r.RelationName;
                    if (sRelation == null) break;
                    GridView view = (GridView)gGridControl.LevelDefaults[sRelation];
                    string sOption = xeDetailDefinition.zAttribValue("Option");
                    XtraGridOption option = new XtraGridOption(sOption);
                    GridSetViewOption(view, option, xeDetailDefinition, r.ChildTable);
                }
            }

            if (gGridOption.ExpandAllMasterRows) XtraGridTools.GridExpandAllMasterRows(gGridView);

            //grid.Tag = new FormGridEvent(grid, gGridDefinition);

            //if (gbTrace) cTrace.StopNestedLevel("SetGridDataSource");

        }
コード例 #3
0
ファイル: XtraGrid.cs プロジェクト: labeuze/source
        private void GridSetViewOption(GridView view, XtraGridOption option, XElement definition, DataTable dt)
        {
            //if (gbTrace) cTrace.StartNestedLevel("GridSetViewOption");

            //if (gbTrace) cTrace.StartNestedLevel("Columns_Clear");
            view.Columns.Clear();
            //if (gbTrace) cTrace.StopNestedLevel("Columns_Clear");

            //if (gbTrace) cTrace.StartNestedLevel("PopulateColumns");
            if (dt != null)
                view.PopulateColumns(dt);
            else
                view.PopulateColumns();
            //if (gbTrace) cTrace.StopNestedLevel("PopulateColumns");

            //((System.ComponentModel.ISupportInitialize)(dxGrid)).BeginInit();
            //((System.ComponentModel.ISupportInitialize)(view)).BeginInit();

            //string sName = definition.zAttribValue("def");
            string sName = definition.zAttribValue("Name");
            if (sName != null) view.Name = sName;
            view.Name = sName;

            //if (gbTrace) cTrace.StartNestedLevel("SetGridColumn***");
            string sColumn = definition.zAttribValue("Column");
            XtraGridTools.SetGridColumn(view, sColumn);

            sColumn = definition.zAttribValue("ColumnCaption");
            XtraGridTools.SetGridColumnCaption(view, sColumn);

            sColumn = definition.zAttribValue("Update");
            XtraGridTools.SetGridColumnUpdate(view, sColumn);

            sColumn = definition.zAttribValue("ReadOnly");
            XtraGridTools.SetGridColumnReadOnly(view, sColumn);

            sColumn = definition.zAttribValue("Hide");
            XtraGridTools.SetGridColumnHide(view, sColumn);
            //if (gbTrace) cTrace.StopNestedLevel("SetGridColumn***");

            // Filter
            string sFilter = definition.zAttribValue("Filter");
            XtraGridTools.SetGridFilter(view, sFilter);

            view.OptionsView.ColumnAutoWidth = option.ColumnAutoWidth;
            view.OptionsView.ShowGroupPanel = option.ShowGroupPanel;
            view.OptionsView.ShowIndicator = !option.NoIndicator;
            view.OptionsView.ShowFilterPanel = !option.NoShowFilterPanel;
            view.OptionsView.ShowColumnHeaders = !option.NoShowColumnHeaders;

            view.OptionsCustomization.AllowFilter = !option.NoAllowFilter;
            view.OptionsCustomization.AllowGroup = !option.NoAllowGroup;
            view.OptionsCustomization.AllowRowSizing = !option.NoAllowRowSizing;
            view.OptionsCustomization.AllowSort = !option.NoAllowSort;

            //RowHeight
            XtraGridTools.SetRowHeight(view, definition.zAttribValue("RowHeight"));

            Font font = XtraGridTools.GetFont(definition.zAttribValue("Font"));
            if (font != null)
            {
                view.ViewStylesInfo.Row.Font = font;
                view.ViewStylesInfo.FocusedRow.Font = font;
                view.ViewStylesInfo.FocusedCell.Font = font;
            }

            StyleOptions style;
            if (XtraGridTools.GetStyleOptions(definition.zAttribValue("StyleFocusedRow"), out style))
                view.ViewStylesInfo.FocusedRow.Options = style;
            if (XtraGridTools.GetStyleOptions(definition.zAttribValue("StyleSelectedRow"), out style))
                view.ViewStylesInfo.SelectedRow.Options = style;
            if (XtraGridTools.GetStyleOptions(definition.zAttribValue("StyleHideSelectionRow"), out style))
                view.ViewStylesInfo.HideSelectionRow.Options = style;

            //OptionsDetail
            view.OptionsDetail.EnableMasterViewMode = option.MasterViewMode;
            view.OptionsDetail.AllowZoomDetail = option.AllowZoomDetail;
            view.OptionsDetail.SmartDetailExpand = option.SmartDetailExpand;
            view.OptionsDetail.AllowExpandEmptyDetails = option.AllowExpandEmptyDetails;
            view.OptionsDetail.AutoZoomDetail = option.AutoZoomDetail;
            view.OptionsDetail.EnableDetailToolTip = option.EnableDetailToolTip;
            view.OptionsDetail.ShowDetailTabs = option.ShowDetailTabs;
            view.OptionsDetail.SmartDetailHeight = option.SmartDetailHeight;

            view.OptionsBehavior.Editable = false;

            view.OptionsView.ShowNewItemRow = false;
            if (!option.ReadOnly)
            {
                if (!option.NoUpdate) view.OptionsBehavior.Editable = true;
                if (!option.NoInsert && !option.NoInsertButton) view.OptionsView.ShowNewItemRow = true;
            }

            if (!option.NoMultiSelect) view.OptionsSelection.MultiSelect = true;

            //if (gbTrace) cTrace.StartNestedLevel("GridSetViewOption_2");
            IEnumerable<XElement> colDefinitions = null;
            if (definition != null)
            {
                colDefinitions = definition.Elements("col");
                foreach (XElement colDefinition in colDefinitions)
                {
                    string sColName = colDefinition.zAttribValue("Name");
                    GridColumn colGrid = view.Columns[sColName];
                    if (colGrid == null)
                    {
                        colGrid = view.Columns.Add();
                        colGrid.Name = sColName;
                        colGrid.Caption = sColName;
                        colGrid.FieldName = sColName;
                        colGrid.VisibleIndex = view.VisibleColumns.Count;
                    }
                    if (colGrid != null)
                    {
                        string sOption = colDefinition.zAttribValue("Option", "");
                        string sCaption = colDefinition.zAttribValue("Caption");
                        if (sCaption != null) colGrid.Caption = sCaption;
                        XtraGridTools.SetGridColumnOption(colGrid, sOption);
                        XtraGridTools.SetGridColumnStyle(colGrid, colDefinition.zAttribValue("Style"));
                        XtraGridTools.SetGridColumnFormatDate(colGrid, colDefinition.zAttribValue("FormatDate"));
                        XtraGridTools.SetGridColumnFormatNum(colGrid, colDefinition.zAttribValue("FormatNum"));
                        //////////SetGridColumnEdit(view, con, dataList, colGrid, col.zAttribValue("Edit"), col);
                        IDbConnection con = GetConnection();
                        DataList dataList = GetDataList();
                        SortedList<string, RepositoryItem> editRepositoryList = GetEditRepositoryList();
                        XtraGridTools gridTools = new XtraGridTools(con, dataList, editRepositoryList);
                        gridTools.SetColumnEdit(colGrid, colDefinition);
                    }
                }
            }
            XtraGridTools.SetGridColumnsDefaultEdit(view);
            //if (gbTrace) cTrace.StopNestedLevel("GridSetViewOption_2");

            //((System.ComponentModel.ISupportInitialize)(view)).EndInit();

            //if (gbTrace) cTrace.StartNestedLevel("BestFitColumns");
            if (!option.NoBestFitColumns)
            {
                view.BestFitMaxRowCount = 50;
                view.BestFitColumns();
            }
            //if (gbTrace) cTrace.StopNestedLevel("BestFitColumns");

            if (colDefinitions != null)
            {
                foreach (XElement col in colDefinitions)
                {
                    GridColumn colGrid = view.Columns[col.zAttribValue("Name")];
                    //XtraGridTools.SetGridColumnWidth(colGrid, col.zAttribValueInt("Width", -1));
                    XtraGridTools.SetGridColumnWidth(colGrid, col.zAttribValue("Width").zTryParseAs<int>(-1));
                }
            }

            string sSort = definition.zAttribValue("Sort");
            XtraGridTools.SetGridSort(view, sSort);

            //XtraGridTools.LoadParameters(view, definition);
            //LoadParameters(view);

            //if (gbTrace) cTrace.StopNestedLevel("GridSetViewOption");
        }
コード例 #4
0
ファイル: XtraGrid.cs プロジェクト: labeuze/source
        public static void SetNavigatorOption(GridControl grid, XtraGridOption option)
        {
            //if (gbTrace) cTrace.StartNestedLevel("GridSetNavigatorOption");

            grid.UseEmbeddedNavigator = !option.NoNavigator;

            grid.EmbeddedNavigator.Buttons.Append.Enabled = false;
            grid.EmbeddedNavigator.Buttons.Edit.Enabled = false;
            grid.EmbeddedNavigator.Buttons.EndEdit.Enabled = false;
            grid.EmbeddedNavigator.Buttons.CancelEdit.Enabled = false;
            grid.EmbeddedNavigator.Buttons.Remove.Enabled = false;

            if (!option.ReadOnly)
            {
                if (!option.NoUpdate)
                {
                    grid.EmbeddedNavigator.Buttons.Edit.Enabled = true;
                    grid.EmbeddedNavigator.Buttons.EndEdit.Enabled = true;
                    grid.EmbeddedNavigator.Buttons.CancelEdit.Enabled = true;
                }
                if (!option.NoInsert && !option.NoInsertButton)
                {
                    grid.EmbeddedNavigator.Buttons.Append.Enabled = true;
                }
                if (!option.NoDelete && !option.NoDeleteButton)
                {
                    grid.EmbeddedNavigator.Buttons.Remove.Enabled = true;
                    if (!option.NoDeleteSelected)
                    {
                        grid.EmbeddedNavigator.ButtonClick += new NavigatorButtonClickEventHandler(XtraGridTools.EmbeddedNavigator_DeleteSelection);
                    }
                }
            }

            grid.EmbeddedNavigator.NavigatorException += new NavigatorExceptionEventHandler(XtraGridTools.EmbeddedNavigator_NavigatorException);

            //if (gbTrace) cTrace.StopNestedLevel();
        }
コード例 #5
0
ファイル: cGrid.cs プロジェクト: labeuze/source
        public void AddDetailDataSource(IDbConnection con, DataList dataList, IDbDataAdapter da, DataTable dt, XElement xe)
        {
            //string sDataName = Xml.GetAttribValue(xe, "def");
            string sDataName = xe.zAttribValue("def");
            if (sDataName == gsDetailName) return;

            //if (gbTrace) cTrace.StartNestedLevel("cGrid_AddDetailDataSource_2");

            Update();
            int iRow = 0;
            if (gGridMaster != null && gGridMaster.MainView != null) iRow = ((GridView)gGridMaster.MainView).FocusedRowHandle;

            ClearDetailDataSource();
            if (xe == null) return;

            string sOption = xe.zAttribValue("Option");
            XtraGridOption option = gOptionDetail = new XtraGridOption(sOption);
            gdaDetail = da; gdtDetail = dt;
            gbDetailDynamic = option.DetailDynamic;


            gsMasterId = xe.zAttribValue("MasterId");
            gsDetailId = xe.zAttribValue("DetailId", gsMasterId);

            GridSetDataSource(gGridDetail, gdtDetail, xe, con, dataList, option);
            gViewDetail.OptionsView.ShowFilterPanel = false;

            DetailUpdateList();
            gsDetailName = sDataName;
            //LoadDetailParameters();
            if (gGridMaster != null && gGridMaster.MainView != null) ((GridView)gGridMaster.MainView).FocusedRowHandle = iRow;

            //if (gbTrace) cTrace.StopNestedLevel("cGrid_AddDetailDataSource_2");
        }
コード例 #6
0
ファイル: cGrid.cs プロジェクト: labeuze/source
        /****************
		<def
			def="b_channel"
			Caption="Channel"
			Cmd="commande sql (select * from b_channel"
			CmdType="StoredProcedure | TableDirect | Text"
			UpdateCmd="update b_channel set shortname = @shortname, longname = @longname where channel_id = @channel_id"
			UpdateCmdType="StoredProcedure | TableDirect | Text"
			Option=""
		>
			<col Name="client_id" Option="ReadOnly, Hide"/>
			<!--<col Name="code" Edit="LookUp" Display="code" Value="code" Cmd="select code, longname channel from b_channel order by isnull(order_no, 9999), longname"/>-->
		</def>
		****************/
        public static void CreateDataSource(IDbConnection con, DataList dataList, XElement xe, out IDbDataAdapter da, out DataTable dt, DataTable dtMaster)
        {
            da = null;
            dt = null;
            bool bDetailDynamic = false;

            if (xe == null) return;

            //if (gbTrace) cTrace.StartNestedLevel("cGrid_CreateDataSource");

            string sOption = xe.zAttribValue("Option");
            XtraGridOption option = new XtraGridOption(sOption);
            bDetailDynamic = option.DetailDynamic;

            string sCmdType, sCmd;
            IDbCommand cmd = null;
            string sTableDef = xe.zAttribValue("TableDef");
            if (sTableDef != null)
            {
                DataContainer data = dataList[sTableDef];
                cmd = data.Command;
                dt = data.DataTable;
                //da = Ado.CreateDataAdapter(cmd);
                da = _ado.CreateDataAdapter(cmd);
            }
            else
            {
                sCmdType = xe.zAttribValue("CmdType", CommandType.Text.ToString());
                sCmd = xe.zAttribValue("Cmd");
                //cmd = Ado.CreateCmd(con, sCmd, Ado.GetCommandType(sCmdType));
                cmd = _ado.CreateCmd(con, sCmd, _ado.GetCommandType(sCmdType));

                if (bDetailDynamic)
                {
                    string sMasterId = xe.zAttribValue("MasterId");
                    AddMasterIdParameter(cmd, dtMaster, sMasterId);
                }

                string sTable = GetTableName(xe);
                dt = new DataTable(sTable);

                //da = Ado.CreateDataAdapter(cmd);
                da = _ado.CreateDataAdapter(cmd);

                //Ado.DataAdapter_FillSchema(da, dt);
                _ado.DataAdapter_FillSchema(da, dt);

                string sPrimaryKey = xe.zAttribValue("PrimaryKey");
                SetPrimaryKey(dt, sPrimaryKey);

                SetDataTableColumnOption(dt, xe);
            }

            //////////////////   Debug pb channel_id
            //if (dt.Columns.Contains("channel_id"))
            //{
            //    cTrace.Trace("PB_Grid.DataContainer.CreateDataTable() : après DataAdapter_FillSchema");
            //    DataColumn col = dt.Columns["channel_id"];
            //    cTrace.Trace("PB_Grid.cGrid.CreateDataSource() : Table {0}, col {1}, AutoIncrementSeed = {2}, AutoIncrementStep = {3}", dt.TableName, col.ColumnName, col.AutoIncrementSeed, col.AutoIncrementStep);

            //    dt.TableNewRow -= new DataTableNewRowEventHandler(Test_TableNewRow_Event);
            //    dt.TableNewRow += new DataTableNewRowEventHandler(Test_TableNewRow_Event);

            //    DataRow row = dt.NewRow();
            //    //col.AutoIncrementSeed = -20;
            //    //cTrace.Trace("PB_Grid.cGrid.CreateDataSource() : Table {0}, col {1}, AutoIncrementSeed = {2}, AutoIncrementStep = {3}", dt.TableName, col.ColumnName, col.AutoIncrementSeed, col.AutoIncrementStep);
            //    //row = dt.NewRow();
            //    //col.AutoIncrementSeed = -1;
            //    //cTrace.Trace("PB_Grid.cGrid.CreateDataSource() : Table {0}, col {1}, AutoIncrementSeed = {2}, AutoIncrementStep = {3}", dt.TableName, col.ColumnName, col.AutoIncrementSeed, col.AutoIncrementStep);
            //    //row = dt.NewRow();
            //}

            sCmdType = xe.zAttribValue("UpdateCmdType", CommandType.Text.ToString());
            sCmd = xe.zAttribValue("UpdateCmd");
            if (sCmd != null)
            {
                //da.UpdateCommand = Ado.CreateCmd(con, sCmd, Ado.GetCommandType(sCmdType), dt);
                da.UpdateCommand = _ado.CreateCmd(con, sCmd, _ado.GetCommandType(sCmdType), dt);
                da.UpdateCommand.UpdatedRowSource = UpdateRowSource.Both;
            }

            bool bInsertCmdDefined = false;
            sCmdType = xe.zAttribValue("InsertCmdType", CommandType.Text.ToString());
            sCmd = xe.zAttribValue("InsertCmd");
            if (sCmd != null)
            {
                //da.InsertCommand = Ado.CreateCmd(con, sCmd, Ado.GetCommandType(sCmdType), dt);
                da.InsertCommand = _ado.CreateCmd(con, sCmd, _ado.GetCommandType(sCmdType), dt);
                da.InsertCommand.UpdatedRowSource = UpdateRowSource.Both;
                bInsertCmdDefined = true;
            }

            sCmdType = xe.zAttribValue("DeleteCmdType", CommandType.Text.ToString());
            sCmd = xe.zAttribValue("DeleteCmd");
            if (sCmd != null)
            {
                //da.DeleteCommand = Ado.CreateCmd(con, sCmd, Ado.GetCommandType(sCmdType), dt);
                da.DeleteCommand = _ado.CreateCmd(con, sCmd, _ado.GetCommandType(sCmdType), dt);
                da.DeleteCommand.UpdatedRowSource = UpdateRowSource.Both;
            }

            //object cb = Ado.CreateCommandBuilder(da);
            object cb = _ado.CreateCommandBuilder(da);
            //if (((!option.ReadOnly && !option.NoUpdate) || option.UpdateCommand) && da.UpdateCommand == null) da.UpdateCommand = Ado.CreateUpdateCommand(cb);
            if (((!option.ReadOnly && !option.NoUpdate) || option.UpdateCommand) && da.UpdateCommand == null) da.UpdateCommand = _ado.CreateUpdateCommand(cb);
            //if (((!option.ReadOnly && !option.NoInsert) || option.InsertCommand) && da.InsertCommand == null) da.InsertCommand = Ado.CreateInsertCommand(cb);
            if (((!option.ReadOnly && !option.NoInsert) || option.InsertCommand) && da.InsertCommand == null) da.InsertCommand = _ado.CreateInsertCommand(cb);
            //if (((!option.ReadOnly && !option.NoDelete) || option.DeleteCommand) && da.DeleteCommand == null) da.DeleteCommand = Ado.CreateDeleteCommand(cb);
            if (((!option.ReadOnly && !option.NoDelete) || option.DeleteCommand) && da.DeleteCommand == null) da.DeleteCommand = _ado.CreateDeleteCommand(cb);

            if (da.InsertCommand != null && !bInsertCmdDefined)
            {
                //string sPrimaryKeyTrace;
                //if (dt.PrimaryKey == null) sPrimaryKeyTrace = "null"; else sPrimaryKeyTrace = dt.PrimaryKey.zToStringValues();
                //cTrace.Trace("PB_Grid.cGrid.CreateDataSource() : Table {0}, PrimaryKey {1}", dt.TableName, sPrimaryKeyTrace);

                IDbCommand cmdInsert = GetCommandWithReturn(da.InsertCommand, dt.PrimaryKey);
                da.InsertCommand.Dispose();
                da.InsertCommand = cmdInsert;
            }
            //if (sTableDef == null && !option.DetailDynamic) Ado.DataAdapter_Fill(da, dt);
            if (sTableDef == null && !option.DetailDynamic) _ado.DataAdapter_Fill(da, dt);

            //string sDataName = Xml.GetAttribValue(xe, "def");
            string sDataName = xe.zAttribValue("def");
            //if (gbTrace) cTrace.StopNestedLevel("cGrid_CreateDataSource");
        }
コード例 #7
0
ファイル: cGrid.cs プロジェクト: labeuze/source
 public static void GridSetViewOption(GridView view, XElement xe, DataTable dt, IDbConnection con, DataList dataList)
 {
     string sOption = xe.zAttribValue("Option");
     XtraGridOption option = new XtraGridOption(sOption);
     GridSetViewOption(view, xe, dt, con, dataList, option);
 }
コード例 #8
0
ファイル: cGrid.cs プロジェクト: labeuze/source
        public void SetMasterDataSource(IDbConnection con, DataList dataList, DataTable dt, IDbDataAdapter da, XElement xe)
        {
            //cTrace.StartNestedLevel("cGrid_SetMasterDataSource");

            //string sDataName = Xml.GetAttribValue(xe, "def");
            string sDataName = xe.zAttribValue("def");
            if (sDataName == gsMasterName) return;
            //Update();
            ClearDataSource();
            //gsMasterId = null;
            //gsDetailId = null;
            //gbDetailDynamic = false;
            if (xe == null) return;
            gdaMaster = da;
            gdtMaster = dt;
            XtraGridOption option = gOptionMaster = new XtraGridOption(xe.zAttribValue("Option"));
            GridSetDataSource(gGridMaster, dt, xe, con, dataList, option);
            gdtMaster.RowDeleting += new DataRowChangeEventHandler(DataTableMaster_RowDeleting);
            gsMasterName = sDataName;
            //LoadMasterParameters();

            //cTrace.StopNestedLevel("cGrid_SetMasterDataSource");
        }
コード例 #9
0
ファイル: cGrid.cs プロジェクト: labeuze/source
        public static void GridCreateDetailView(GridControl dxGrid, DataTable dt, string sRelation, XElement xe, IDbConnection con, DataList dataList)
        {
            string sOption = xe.zAttribValue("Option");
            XtraGridOption option = new XtraGridOption(sOption);

            GridView view = new GridView();
            view.GridControl = dxGrid;
            dxGrid.LevelDefaults.Add(sRelation, view);
            GridSetViewOption(view, xe, dt, con, dataList, option);
        }
コード例 #10
0
ファイル: cGrid.cs プロジェクト: labeuze/source
        public static void GridSetOption(GridControl dxGrid, XElement xe, DataTable dt, IDbConnection con, DataList dataList)
        {
            string sOption = xe.zAttribValue("Option");
            XtraGridOption option = new XtraGridOption(sOption);
            dxGrid.ForceInitialize();

            //GridSetNavigatorOption(dxGrid, option);
            XtraGridTools.SetNavigatorOption(dxGrid, option);

            GridSetViewOption((GridView)dxGrid.MainView, xe, dt, con, dataList, option);
            dxGrid.Leave += new EventHandler(GridControl_Leave);
        }
コード例 #11
0
ファイル: cGrid.cs プロジェクト: labeuze/source
        private static void GridSetDataSource(GridControl grid, DataTable dt, XElement xe, IDbConnection con, DataList dataList, XtraGridOption option)
        {
            //if (gbTrace) cTrace.StartNestedLevel("cGrid_GridSetDataSource");

            //if (gbTrace) cTrace.StartNestedLevel("EndEvent");
            if (grid.Tag is FormGridEvent)
                ((FormGridEvent)grid.Tag).End();
            //if (gbTrace) cTrace.StopNestedLevel("EndEvent");

            ((GridView)grid.MainView).CollapseAllDetails();
            GridClearDataSource(grid);

            //if (option.MasterViewMode) GridCreateDetailViews(grid, dt);
            if (option.MasterViewMode) XtraGridTools.GridCreateDetailViews(grid, dt);

            //if (gbTrace) cTrace.StartNestedLevel("SetDataSource");
            grid.DataSource = dt;
            grid.ForceInitialize();
            //if (gbTrace) cTrace.StopNestedLevel("SetDataSource");

            //GridSetNavigatorOption(grid, option);
            XtraGridTools.SetNavigatorOption(grid, option);

            GridSetViewOption((GridView)grid.MainView, xe, dt, con, dataList, option);

            grid.Leave += new EventHandler(GridControl_Leave);

            if (xe != null && option.MasterViewMode)
            {
                IEnumerator<XElement> xeDetailEnum = xe.Elements("def").GetEnumerator();
                foreach (DataRelation r in dt.ChildRelations)
                {
                    if (!xeDetailEnum.MoveNext()) break;
                    XElement xeDetail = xeDetailEnum.Current;
                    string sRelation = r.RelationName;
                    if (sRelation == null) break;
                    GridView view = (GridView)grid.LevelDefaults[sRelation];
                    GridSetViewOption(view, xeDetail, r.ChildTable, con, dataList);
                }
            }

            //if (option.ExpandAllMasterRows) GridExpandAllMasterRows(grid);
            if (option.ExpandAllMasterRows) XtraGridTools.GridExpandAllMasterRows((GridView)grid.MainView);

            grid.Tag = new FormGridEvent(grid, xe);

            //if (gbTrace) cTrace.StopNestedLevel("cGrid_GridSetDataSource");
        }
コード例 #12
0
ファイル: cGrid.cs プロジェクト: labeuze/source
 public static void GridSetDataSource(GridControl dxGrid, DataTable dt, XElement xe, IDbConnection con, DataList dataList)
 {
     //if (xe == null) return;
     string sOption = null;
     if (xe != null)
         sOption = xe.zAttribValue("Option");
     XtraGridOption option = new XtraGridOption(sOption);
     GridSetDataSource(dxGrid, dt, xe, con, dataList, option);
 }
コード例 #13
0
ファイル: cGrid.cs プロジェクト: labeuze/source
 private static IDbDataAdapter CreateDataAdapter(IDbCommand cmd, XtraGridOption option)
 {
     //IDbDataAdapter da = Ado.CreateDataAdapter(cmd);
     IDbDataAdapter da = _ado.CreateDataAdapter(cmd);
     //object cb = Ado.CreateCommandBuilder(da);
     object cb = _ado.CreateCommandBuilder(da);
     //if ((!option.ReadOnly && !option.NoUpdate) || option.UpdateCommand) da.UpdateCommand = Ado.CreateUpdateCommand(cb);
     if ((!option.ReadOnly && !option.NoUpdate) || option.UpdateCommand) da.UpdateCommand = _ado.CreateUpdateCommand(cb);
     //if ((!option.ReadOnly && !option.NoInsert) || option.InsertCommand) da.InsertCommand = Ado.CreateInsertCommand(cb);
     if ((!option.ReadOnly && !option.NoInsert) || option.InsertCommand) da.InsertCommand = _ado.CreateInsertCommand(cb);
     //if ((!option.ReadOnly && !option.NoDelete) || option.DeleteCommand) da.DeleteCommand = Ado.CreateDeleteCommand(cb);
     if ((!option.ReadOnly && !option.NoDelete) || option.DeleteCommand) da.DeleteCommand = _ado.CreateDeleteCommand(cb);
     return da;
 }