コード例 #1
0
ファイル: Tree.aspx.cs プロジェクト: vahtel65/Aspect_loc
        private void BindGrid()
        {
            DataSet data = null;
            ConfigurationTreeProvider provider = null;
            List<GridColumn> columns = new List<GridColumn>();
            try
            {
                provider = new ConfigurationTreeProvider();
                if (provider != null)
                {
                    Aspect.Domain.Product prod = provider.GetProduct(this.ProductID);
                    if (prod == null) return;
                    this.Title = HeaderLiteral.Text = string.Format(HeaderLiteral.Text, prod.PublicName, prod.Version == null ? string.Empty : prod.Version.ToString());
                    HeaderDateLiteral.Text = string.Format(HeaderDateLiteral.Text, DateTime.Now.ToShortDateString(), DateTime.Now.ToLongTimeString());
                    //Response.Write(provider.getQuery(new Guid(node.Value), this.User.ID, this.OrderExpression, this.SearchConditions));
                    //return;
                    data = provider.GetList(this.RequestClassificationTreeID, this.ProductID, this.User.ID, this.SearchConditions);
                    if (ShowSelected && !String.IsNullOrEmpty(SelectedProductsHidden.Value))
                    {
                        string[] ids = SelectedProductsHidden.Value.Split(',').Select(s => string.Format("CONVERT('{0}','System.Guid')", s)).ToArray();
                        data.Tables[0].DefaultView.RowFilter = string.Format("ID in ({0})", string.Join(",", ids));
                    }
                    columns = provider.GetGridColumns(this.User.ID, this.RequestClassificationTreeID, FieldPlaceHolder.Grid);
                }

            }
            finally
            {
                if (provider != null) provider.Dispose();
            }
            if (data != null && data.Tables.Count > 0)
            {
                ProductGrid.DataSource = data.Tables[0].DefaultView;
                ProductGrid.DataBind();

                if (data.Tables[0].Rows.Count > 0)
                {
                    string pid = data.Tables[0].Rows[0][Common.IDColumnTitle].ToString();
                    string function = string.Format("<script language=JavaScript>onGridViewRowSelectedCallback('{0}','{1}', document.getElementById('{2}'));</script>", pid, this.RequestClassificationTreeID, ProductGrid.Rows[0].ClientID);
                    this.ClientScript.RegisterStartupScript(this.GetType(), "mainview", function);
                }

                this.AppendGridHeader(columns);
            }
        }
コード例 #2
0
ファイル: TreeEx.aspx.cs プロジェクト: vahtel65/Aspect_loc
        private void BindGrid()
        {
            DataSet data = null;
            ConfigurationTreeProvider provider = null;
            List<GridColumn> columns = new List<GridColumn>();
            try
            {
                provider = new ConfigurationTreeProvider();
                if (provider != null)
                {
                    Aspect.Domain.Product prod = provider.GetProduct(this.ProductID);
                    if (prod == null) return;
                    this.Title = HeaderLiteral.Text = string.Format(HeaderLiteral.Text, prod.PublicName, prod.Version == null ? string.Empty : prod.Version.ToString());
                    HeaderDateLiteral.Text = string.Format(HeaderDateLiteral.Text, DateTime.Now.ToShortDateString(), DateTime.Now.ToLongTimeString());
                    //Response.Write(provider.getQuery(new Guid(node.Value), this.User.ID, this.OrderExpression, this.SearchConditions));
                    //return;
                    data = provider.GetList(this.RequestClassificationTreeID, this.ProductID, this.User.ID, this.SearchConditions);
                    if (ShowSelected && !String.IsNullOrEmpty(SelectedProductsHidden.Value))
                    {
                        string[] ids = SelectedProductsHidden.Value.Split(',').Select(s => string.Format("CONVERT('{0}','System.Guid')", s)).ToArray();
                        data.Tables[0].DefaultView.RowFilter = string.Format("ID in ({0})", string.Join(",", ids));
                    }
                    columns = provider.GetGridColumns(this.User.ID, this.RequestClassificationTreeID, FieldPlaceHolder.Grid);
                }

            }
            finally
            {
                if (provider != null) provider.Dispose();
            }
            if (data != null && data.Tables.Count > 0)
            {
                //ProductGrid.DataSource = data.Tables[0].DefaultView;
                //ProductGrid.DataBind();

                Stack<Ext.Net.TreeNodeCollection> stackRoots = new Stack<Ext.Net.TreeNodeCollection>();
                Ext.Net.TreeNodeCollection currentRoot = (ProductTree.Root.First() as Ext.Net.TreeNode).Nodes;
                int? prevLevel = null, curLevel = null;

                foreach (DataRow row in data.Tables[0].Rows)
                {
                    curLevel = Convert.ToInt32(row["Level"]);
                    if (!prevLevel.HasValue) prevLevel = curLevel;

                    Ext.Net.TreeNode node = new Ext.Net.TreeNode();
                    node.Checked = Ext.Net.ThreeStateBool.False;
                    foreach(GridColumn column in columns)
                    {
                        node.CustomAttributes.Add(new Ext.Net.ConfigItem(column.DataItem.Replace('.', '_'), row[column.DataItem].ToString(), Ext.Net.ParameterMode.Value));
                    }
                    node.CustomAttributes.Add(new Ext.Net.ConfigItem("ProductID", row["ID"].ToString(), Ext.Net.ParameterMode.Value));
                    if (curLevel > prevLevel)
                    {
                        stackRoots.Push(currentRoot);
                        currentRoot = (currentRoot.Last() as Ext.Net.TreeNode).Nodes;
                    }
                    if (curLevel < prevLevel)
                    {
                        currentRoot = stackRoots.Pop();
                    }
                    currentRoot.Add(node);
                    prevLevel = curLevel;
                }

                if (data.Tables[0].Rows.Count > 0)
                {
                    string function = String.Format("Ext.namespace('App'); App.cid = '{0}'; ", this.RequestClassificationTreeID);
                    ResourceManager1.AddAfterClientInitScript(function);
                }

                this.AppendGridHeader(columns);
            }
        }