/// <summary>
        /// 把DataTable的值加入到Grid中
        /// </summary>
        /// <param name="grid"></param>
        /// <param name="dt"></param>
        /// <param name="setValues"></param>
        public static void AddDataTableRows(this IGrid grid, System.Data.DataTable dt, SetOtherRowValues setValues)
        {
            if (dt == null)
            {
                return;
            }

            Xceed.Grid.DataRow row;
            for (int i = 0; i < dt.Rows.Count; ++i)
            {
                row = AddDataRow(grid, dt.Rows[i]);

                if (setValues != null)
                {
                    setValues(row);
                }
            }
        }
Exemple #2
0
        /// <summary>
        /// 加入DataTable到DetailGrid中
        /// </summary>
        /// <param name="grid"></param>
        /// <param name="dt"></param>
        /// <param name="primaryKeyName"></param>
        /// <param name="setValues"></param>
        public static void AddDetailDataTableRows(this IGrid grid, System.Data.DataTable dt, string primaryKeyName, SetOtherRowValues setValues)
        {
            System.Collections.Generic.Dictionary <string, Xceed.Grid.DataRow> masterRows =
                new System.Collections.Generic.Dictionary <string, Xceed.Grid.DataRow>();
            foreach (Xceed.Grid.DataRow row in grid.DataRows)
            {
                if (!masterRows.ContainsKey(row.Cells[primaryKeyName].Value.ToString()))
                {
                    masterRows[row.Cells[primaryKeyName].Value.ToString()] = row;
                }
            }

            for (int i = 0; i < dt.Rows.Count; ++i)
            {
                Xceed.Grid.DataRow row;
                if (!masterRows.ContainsKey(dt.Rows[i][primaryKeyName].ToString()))
                {
                    row = grid.AddDataRow(dt.Rows[i]);
                    masterRows[dt.Rows[i][primaryKeyName].ToString()] = row;
                }

                MyDetailGrid detailGrid =
                    masterRows[dt.Rows[i][primaryKeyName].ToString()].DetailGrids[0] as MyDetailGrid;
                row = detailGrid.AddDataRow(dt.Rows[i]);

                if (setValues != null)
                {
                    setValues(row);
                }
            }
        }
        /// <summary>
        /// 加入DataTable到DetailGrid中
        /// </summary>
        /// <param name="grid"></param>
        /// <param name="dt"></param>
        /// <param name="primaryKeyName"></param>
        /// <param name="setValues"></param>
        public static void AddDetailDataTableRows(this IGrid grid, System.Data.DataTable dt, string primaryKeyName, SetOtherRowValues setValues)
        {
            System.Collections.Generic.Dictionary<string, Xceed.Grid.DataRow> masterRows =
                new System.Collections.Generic.Dictionary<string, Xceed.Grid.DataRow>();
            foreach (Xceed.Grid.DataRow row in grid.DataRows)
            {
                if (!masterRows.ContainsKey(row.Cells[primaryKeyName].Value.ToString()))
                {
                    masterRows[row.Cells[primaryKeyName].Value.ToString()] = row;
                }
            }

            for (int i = 0; i < dt.Rows.Count; ++i)
            {
                Xceed.Grid.DataRow row;
                if (!masterRows.ContainsKey(dt.Rows[i][primaryKeyName].ToString()))
                {
                    row = grid.AddDataRow(dt.Rows[i]);
                    masterRows[dt.Rows[i][primaryKeyName].ToString()] = row;
                }

                MyDetailGrid detailGrid =
                    masterRows[dt.Rows[i][primaryKeyName].ToString()].DetailGrids[0] as MyDetailGrid;
                row = detailGrid.AddDataRow(dt.Rows[i]);

                if (setValues != null)
                {
                    setValues(row);
                }
            }
        }
Exemple #4
0
        /// <summary>
        /// 把DataTable的值加入到Grid中
        /// </summary>
        /// <param name="grid"></param>
        /// <param name="dt"></param>
        /// <param name="setValues"></param>
        public static void AddDataTableRows(this IGrid grid, System.Data.DataTable dt, SetOtherRowValues setValues)
        {
            if (dt == null)
            {
                return;
            }

            Xceed.Grid.DataRow row;
            for (int i = 0; i < dt.Rows.Count; ++i)
            {
                row = AddDataRow(grid, dt.Rows[i]);

                if (setValues != null)
                {
                    setValues(row);
                }
            }
        }