Exemplo n.º 1
0
    public static void InsertAttributeColumnsByTemplateColumn(PXGridColumnCollection columns, PXFieldCollection fields)
    {
        var attributeFields = fields.Where(f => f.StartsWith(Template) && char.IsDigit(f.Last())).ToList();

        int          templateFieldIndex = -1;
        PXGridColumn templateColumn     = null;

        foreach (PXGridColumn column in columns)
        {
            if (column.DataField == TemplateField)
            {
                templateFieldIndex = columns.IndexOf(column);
                templateColumn     = column;
            }

            attributeFields.Remove(column.DataField);
        }

        if (templateColumn != null)
        {
            foreach (string attributeField in attributeFields)
            {
                var newColumn = new PXGridColumn();
                newColumn.CopyFrom(templateColumn);
                newColumn.DataField = attributeField;
                columns.Insert(++templateFieldIndex, newColumn);
            }
        }
    }
Exemplo n.º 2
0
	protected void Page_Init(object sender, EventArgs e)
	{	
		for (int i = 1; ; i++)
		{
			string fieldName = "Period" + i;
			if (!ds.DataGraph.Caches["GLBudgetLine"].Fields.Contains(fieldName))
			{
				break;
			}

			PXGridColumn col = new PXGridColumn
			{
				DataField = fieldName,
				DataType = TypeCode.Decimal,
				Decimals = 2,
				TextAlign = HorizontalAlign.Right,
				AllowNull = false,
				RenderEditorText = true,
				AutoCallBack = true,
				Width = Unit.Pixel(70)
			};
			col.Header.Text = fieldName;
			var grid = sp1.FindControl("grid") as PXGrid;
			grid.Columns.Add(col);
		}
	}
Exemplo n.º 3
0
    public static void EnableCommitChangesAndMoveExtraColumnAtTheEnd(PXGridColumnCollection columns, int?extraColumnWidth = null, string linkCommand = null)
    {
        PXGridColumn extra = null;

        foreach (PXGridColumn col in columns)
        {
            col.CommitChanges = true;
            if (col.DataField == "Extra")
            {
                extra = col;
            }

            if (col.DataField.StartsWith(InventoryMatrixEntry.Template) && char.IsDigit(col.DataField.Last()))
            {
                col.LinkCommand = linkCommand;
            }
        }
        if (extra != null)
        {
            columns.Remove(extra);
            if (extraColumnWidth != null)
            {
                extra.Width = new Unit((int)extraColumnWidth);
            }
            extra.AllowDragDrop = false;
            extra.AllowMove     = false;
            extra.AllowResize   = false;
            columns.Add(extra);
        }
    }
    protected void Page_Init(object sender, EventArgs e)
    {
        for (int i = 1; ; i++)
        {
            string fieldName = "Period" + i;
            if (!ds.DataGraph.Caches["GLBudgetLine"].Fields.Contains(fieldName))
            {
                break;
            }

            PXGridColumn col = new PXGridColumn
            {
                DataField        = fieldName,
                DataType         = TypeCode.Decimal,
                Decimals         = 2,
                TextAlign        = HorizontalAlign.Right,
                AllowNull        = false,
                RenderEditorText = true,
                AutoCallBack     = true,
                Width            = Unit.Pixel(70)
            };
            col.Header.Text = fieldName;
            var grid = sp1.FindControl("grid") as PXGrid;
            grid.Columns.Add(col);
        }
    }
Exemplo n.º 5
0
	protected void CreateColumns(PXDataSourceViewSchema schema, PXGrid grid)
	{
		List<string> list = new List<string>();
		foreach (PXGridColumn col in grid.Levels[0].Columns)
		{ 
			if (!String.IsNullOrEmpty(col.DataField))
			{
				list.Add(col.DataField);
			}
		}
		foreach (PXFieldState field in schema.GetFields())
		{
			if (!AUAuditInquire.FORBIDDEN_COLUMNS.Contains(field.Name) && field.Name.EndsWith(AUAuditInquire.VIRTUAL_FIELD_SUFFIX) && !list.Contains(field.Name))
			{
				PXGridColumn col = new PXGridColumn();
				col.DataField = field.Name;
				col.DataType = Type.GetTypeCode(field.DataType);
				col.TextAlign = HorizontalAlign.Right;
				col.Width = Unit.Pixel(120);
				switch (col.DataType)
				{
					case TypeCode.Boolean:
						col.Width = Unit.Pixel(60);
						col.Type = GridColumnType.CheckBox;
						col.TextAlign = HorizontalAlign.Center;
						break;
					case TypeCode.DateTime:
						col.TextAlign = HorizontalAlign.Left;
						col.DisplayFormat = "g";
						break;
					case TypeCode.String:
						col.TextAlign = HorizontalAlign.Left;
						break;
				}
				col.Visible = true;
				col.Header.Text = field.DisplayName == field.Name
                    ? field.DisplayName.Substring(0, field.DisplayName.Length - AUAuditInquire.VIRTUAL_FIELD_SUFFIX.Length)
					: field.DisplayName;
				col.AllowShowHide = AllowShowHide.Server;
				grid.Columns.Add(col);
			}

			list.Remove(field.Name);
		}

		foreach (string field in list)
		{
			PXGridColumn col = GetColumn(grid, field);
			if (col != null) grid.Levels[0].Columns.Remove(col);
		}

        grid.FastFilterFields = grid.Columns.Items.Select(col => col.DataField).ToArray();

		//if (grid.Levels[0].Columns.Count <= 1) grid.AllowAutoHide = true;
	}
Exemplo n.º 6
0
    protected void CreateColumns(PXDataSourceViewSchema schema, PXGrid grid)
    {
        var gridColumn = sp1.FindControl("gridColumn") as PXGrid;

        List <string> list = new List <string>();

        foreach (PXGridColumn col in grid.Levels[0].Columns)
        {
            if (!String.IsNullOrEmpty(col.DataField))
            {
                list.Add(col.DataField);
            }
        }
        foreach (PXFieldState field in schema.GetFields())
        {
            if (field.Name.Length <= 3 || field.Name.EndsWith("_StyleID"))
            {
                if (!list.Contains(field.Name))
                {
                    PXGridColumn col = new PXGridColumn();
                    col.DataField     = field.Name;
                    col.DataType      = Type.GetTypeCode(field.DataType);
                    col.Width         = Unit.Pixel(150);
                    col.Header.Text   = field.DisplayName;
                    col.AllowShowHide = AllowShowHide.Server;
                    if (grid == gridColumn)
                    {
                        col.TextField = field.Name + "_Text";
                    }
                    else if (field.Name.Length <= 3)
                    {
                        col.EditorID = "edColHeader";
                    }
                    grid.Columns.Add(col);
                }
            }
            list.Remove(field.Name);
        }
        foreach (string field in list)
        {
            foreach (PXGridColumn col in grid.Levels[0].Columns)
            {
                if (col.DataField == field)
                {
                    grid.Levels[0].Columns.Remove(col);
                    break;
                }
            }
        }
    }
    protected void CreateColumns(IEnumerable <PXFieldState> schemaFields, PXGrid grid, Dictionary <string, string> locales, string[] languages)
    {
        if (locales != null)
        {
            List <string> list = grid.Levels[0].Columns
                                 .Cast <PXGridColumn>()
                                 .Where(col => !string.IsNullOrEmpty(col.DataField))
                                 .Select(col => col.DataField)
                                 .Concat(TranslationMaint.MultilingualTranslator.FORBIDDEN_COLUMNS)
                                 .ToList();
            PXFieldState[] dynamicFields = schemaFields
                                           .Where(field => list.All(col => string.Compare(field.Name, col, StringComparison.InvariantCultureIgnoreCase) != 0))
                                           .ToArray();
            //Array.Sort(dynamicFields, (f1, f2) => string.Compare(locales[f1.Name], locales[f2.Name], StringComparison.InvariantCultureIgnoreCase));

            foreach (PXFieldState field in dynamicFields)
            {
                PXGridColumn col = new PXGridColumn
                {
                    DataField     = field.Name,
                    DataType      = TypeCode.String,
                    Multiline     = true,
                    TextAlign     = HorizontalAlign.Left,
                    Width         = Unit.Pixel(250),
                    Visible       = true,
                    AllowShowHide = AllowShowHide.Server,
                };

                col.Header.Text = locales[field.Name];
                grid.Columns.Add(col);
            }

            List <PXGridColumn> columnsToDelete = grid.Levels[0].Columns
                                                  .Cast <PXGridColumn>()
                                                  .Where(column => locales.ContainsKey(column.DataField) && !languages.Contains(column.DataField))
                                                  .ToList();
            foreach (PXGridColumn column in columnsToDelete)
            {
                grid.Levels[0].Columns.Remove(column);
            }
        }
    }
    protected void CreateColumns(PXDataSourceViewSchema schema, PXGrid grid)
    {
        List <string> list = new List <string>();

        foreach (PXGridColumn col in grid.Levels[0].Columns)
        {
            if (!String.IsNullOrEmpty(col.DataField))
            {
                list.Add(col.DataField);
            }
        }
        foreach (PXFieldState field in schema.GetFields())
        {
            if (!AUAuditInquire.FORBIDDEN_COLUMNS.Contains(field.Name) && field.Name.EndsWith(AUAuditInquire.VIRTUAL_FIELD_SUFFIX) && !list.Contains(field.Name))
            {
                PXGridColumn col = new PXGridColumn();
                col.DataField = field.Name;
                col.DataType  = Type.GetTypeCode(field.DataType);
                col.TextAlign = HorizontalAlign.Right;
                col.Width     = Unit.Pixel(120);
                switch (col.DataType)
                {
                case TypeCode.Boolean:
                    col.Width     = Unit.Pixel(60);
                    col.Type      = GridColumnType.CheckBox;
                    col.TextAlign = HorizontalAlign.Center;
                    break;

                case TypeCode.DateTime:
                    col.TextAlign     = HorizontalAlign.Left;
                    col.DisplayFormat = "g";
                    break;

                case TypeCode.String:
                    col.TextAlign = HorizontalAlign.Left;
                    break;
                }
                col.Visible     = true;
                col.Header.Text = field.DisplayName == field.Name
                    ? field.DisplayName.Substring(0, field.DisplayName.Length - AUAuditInquire.VIRTUAL_FIELD_SUFFIX.Length)
                                        : field.DisplayName;
                col.AllowShowHide = AllowShowHide.Server;
                grid.Columns.Add(col);
            }

            list.Remove(field.Name);
        }

        foreach (string field in list)
        {
            PXGridColumn col = GetColumn(grid, field);
            if (col != null)
            {
                grid.Levels[0].Columns.Remove(col);
            }
        }

        grid.FastFilterFields = grid.Columns.Items.Select(col => col.DataField).ToArray();

        //if (grid.Levels[0].Columns.Count <= 1) grid.AllowAutoHide = true;
    }
Exemplo n.º 9
0
	protected void CreateColumns(PXDataSourceViewSchema schema, PXGrid grid)
	{
        var gridColumn = sp1.FindControl("gridColumn") as PXGrid;
        
        List<string> list = new List<string>();
		foreach (PXGridColumn col in grid.Levels[0].Columns)
		{
			if (!String.IsNullOrEmpty(col.DataField))
			{
				list.Add(col.DataField);
			}
		}
		foreach (PXFieldState field in schema.GetFields())
		{
			if (field.Name.Length <= 3 || field.Name.EndsWith("_StyleID"))
			{
				if (!list.Contains(field.Name))
				{
					PXGridColumn col = new PXGridColumn();
					col.DataField = field.Name;
					col.DataType = Type.GetTypeCode(field.DataType);
					col.Width = Unit.Pixel(150);
					col.Header.Text = field.DisplayName;
					col.AllowShowHide = AllowShowHide.Server;
					if (grid == gridColumn)
					{
						col.TextField = field.Name + "_Text";
					}
					else if (field.Name.Length <= 3)
					{
						col.EditorID = "edColHeader";
					}
					grid.Columns.Add(col);
				}
			}
			list.Remove(field.Name);
		}
		foreach (string field in list)
		{
			foreach (PXGridColumn col in grid.Levels[0].Columns)
			{
				if (col.DataField == field)
				{
					grid.Levels[0].Columns.Remove(col);
					break;
				}
			}
		}
	}
    void InitProcessing()
    {
        if (_isInitProcessing)
        {
            return;
        }

        _isInitProcessing = true;


        var p = (PXPage)this.Page;

        if (p.DefaultDataSource == null)
        {
            return;
        }

        var graph = p.DefaultDataSource.DataGraph;

        if (!graph.IsProcessing || PXGraph.ProxyIsActive)
        {
            return;
        }

        var ds = p.DefaultDataSource;

        foreach (string command in ds.GetCommandsForProcessingGrid())
        {
            this.gridDetails.ActionBar.CustomItems.Add(new PXToolBarButton {
                CommandSourceID = ds.ID, CommandName = command
            });
        }



        //ViewProcessingResults.AutoRepaint = true;
        //gridDetails.AutoRepaint = true;
        //PanelProgress.LoadOnDemand = false;
        //PanelLongRunDetails.LoadOnDemand = false;

        var pview = graph.Views.Where(_ => _.Value is IPXProcessingView).ToDictionary(_ => _.Key);

        var list = ControlHelper.GetDataControls(this.Page, null);

        foreach (var control in list)
        {
            if (!(control is PXGrid))
            {
                continue;
            }
            if (control == gridDetails)
            {
                continue;
            }
            var srcGrid = (PXGrid)control;
            //var select = graph.Views[srcGrid.DataMember];
            if (pview.ContainsKey(srcGrid.DataMember))
            {
                this.gridDetails.TemplateEditors.Clear();
                foreach (var srcGridTemplateEditor in srcGrid.TemplateEditors)
                {
                    this.gridDetails.TemplateEditors.Add(srcGridTemplateEditor.Key, srcGridTemplateEditor.Value);
                }
                foreach (PXGridColumn src in srcGrid.Columns.AspxColumns)
                {
                    if (src.DataField == "Selected")
                    {
                        continue;
                    }
                    var dest = this.gridDetails.Columns[src.DataField];

                    if (dest == null)
                    {
                        dest = new PXGridColumn
                        {
                            DataField = src.DataField
                        };
                        dest.CopyFrom(src);
                        dest.ViewName = src.ViewName;
                        this.gridDetails.Columns.Add(dest);
                    }
                    else
                    {
                        dest.CopyFrom(src);
                        dest.ViewName = src.ViewName;
                    }

                    dest.Width = src.Width;
                }

                break;
            }
        }
    }