Wednesday, August 29, 2012

  private void buildTopLevel()
        {
            if (Session["UserName"] != null)
            {
                grdGroups.ID = "Grid1";
                grdGroups.Width = 750;
                grdGroups.ShowFooter = true;
                grdGroups.AutoTheming = true;
                // grid.ClientIDMode = ClientIDMode.AutoID;
                grdGroups.PagerStyle = ComponentArt.Web.UI.GridPagerStyle.Numbered;
                DataSet ds = new DataSet();
                List<GroupDO> objListGroupDO = new List<GroupDO>();
                ObjGroupDO.AccountID = Convert.ToInt64(Session["AccountID"]);
                ObjGroupDO.UEmail = Session["UserName"].ToString();
                objListGroupDO = Group.SelectAll(ObjGroupDO.AccountID, ObjGroupDO.UEmail);
                ds = ConvertListToDataSet(objListGroupDO);
                ViewState["Data"] = ds;
                if (ds.Tables[0].Rows.Count > 0)
                {
                    int levels = Convert.ToInt32(ds.Tables[0].Compute("max(Level)", string.Empty));
                    objListGroupDO.Clear();
                    objListGroupDO = Activayt.Business.Group.SelectGroups(ObjGroupDO.AccountID, ObjGroupDO.UEmail);
                    ds = null;
                    ds = ConvertListToDataSet(objListGroupDO);
                    grdGroups.Levels.Clear();
                    for (int i = 0; i < levels; i++)
                    {
                        GridLevel gridLevel = new GridLevel();
                        grdGroups.Levels.Add(gridLevel);
                        grdGroups.Levels[i].DataKeyField = "GroupID";
                        GridColumn column1 = new GridColumn();
                        column1.DataField = "GroupName";
                        GridColumn column2 = new GridColumn();
                        column2.DataField = "Administrator";
                        GridColumn column3 = new GridColumn();
                        column3.DataField = "Manager";
                        GridColumn column4 = new GridColumn();
                        column4.DataField = "Analyst";
                        GridColumn column5 = new GridColumn();
                        column5.DataField = "GroupID";
                        gridLevel.Columns.Add(column1);
                        gridLevel.Columns.Add(column2);
                        gridLevel.Columns.Add(column3);
                        gridLevel.Columns.Add(column4);
                        gridLevel.Columns.Add(column5);
                        grdGroups.Levels[i].Columns[4].Visible = false;
                    }
                    grdGroups.DataSource = ds.Tables[0];
                    int i1 = grdGroups.Levels.Count;
                }
            }
        }
        public void OnNeedRebind(object sender, EventArgs oArgs)
        {
            grdGroups.DataBind();
        }
        public void OnNeedDataSource(object sender, EventArgs oArgs)
        {
            buildTopLevel();
        }
        public void OnNeedChildData(object sender, ComponentArt.Web.UI.GridNeedChildDataSourceEventArgs args)
        {
            DataSet ds=(DataSet)ViewState["Data"];
            int Level = Convert.ToInt32(ds.Tables[0].Compute("max(Level)", string.Empty));
            for (int i = 0; i < Level; i++)
            {
                if (args.Item.Level == i)
                {
                    DataView dv = ds.Tables[0].DefaultView;
                    dv.RowFilter = "ParentGroupID=" + args.Item["GroupID"];
                    args.DataSource = dv.ToTable();
                }

            }

        }
        public void OnPageChanged(object sender, ComponentArt.Web.UI.GridPageIndexChangedEventArgs oArgs)
        {
            grdGroups.CurrentPageIndex = oArgs.NewIndex;
        }
        public void OnSort(object sender, ComponentArt.Web.UI.GridSortCommandEventArgs oArgs)
        {
            grdGroups.Sort = oArgs.SortExpression;
        }
        #region Web Form Designer generated code
        override protected void OnInit(EventArgs e)
        {
            //
            // CODEGEN: This call is required by the ASP.NET Web Form Designer.
            //
            InitializeComponent();
            base.OnInit(e);
        }

        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            this.Load += new System.EventHandler(this.Page_Load);
            grdGroups.NeedRebind += new ComponentArt.Web.UI.Grid.NeedRebindEventHandler(OnNeedRebind);
            grdGroups.NeedDataSource += new ComponentArt.Web.UI.Grid.NeedDataSourceEventHandler(OnNeedDataSource);
            grdGroups.NeedChildDataSource += new ComponentArt.Web.UI.Grid.NeedChildDataSourceEventHandler(OnNeedChildData);
            grdGroups.PageIndexChanged += new ComponentArt.Web.UI.Grid.PageIndexChangedEventHandler(OnPageChanged);
            grdGroups.SortCommand += new ComponentArt.Web.UI.Grid.SortCommandEventHandler(OnSort);
        }
        #endregion

No comments:

Post a Comment