Пример #1
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;
	}
Пример #2
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;
                }
            }
        }
    }
Пример #3
0
    /// <summary>
    /// Refresh the list of data fields using specified view name.
    /// </summary>
    private List <PXFieldSchema> RefreshFieldsList(PXDataSourceViewSchema schema, RMReportMaint graph)
    {
        PX.Data.PXFieldState[] fields = schema.GetFields();
        List <PXFieldSchema>   list   = new List <PXFieldSchema>();

        if (fields != null)
        {
            foreach (PX.Data.PXFieldState f in fields)
            {
                if (String.IsNullOrEmpty(f.Name) || !f.Name.StartsWith("DataSource", StringComparison.OrdinalIgnoreCase) && !f.Name.StartsWith("Request", StringComparison.OrdinalIgnoreCase) && !f.Name.StartsWith("UsrRequest", StringComparison.OrdinalIgnoreCase))
                {
                    continue;
                }

                string dsField = f.Name;
                if (dsField.StartsWith("DataSource", StringComparison.OrdinalIgnoreCase))
                {
                    dsField = dsField.Substring(10);
                }
                else if (f.Name.StartsWith("Request", StringComparison.OrdinalIgnoreCase))
                {
                    dsField = dsField.Substring(7);
                }
                else
                {
                    dsField = "Usr" + dsField.Substring(10);
                }

                PXFieldState dsState = graph.DataSourceByID.Cache.GetStateExt(null, dsField) as PXFieldState;

                if (dsState == null || !dsState.Visible)
                {
                    continue;
                }

                TypeCode dataType = Type.GetTypeCode(f.DataType);
                if (dataType == TypeCode.Object)
                {
                    continue;
                }

                PXFieldSchema item = new PXFieldSchema(true, f.Name, dataType);
                item.ControlType = PXSchemaGenerator.GetControlType(f);
                item.PrimaryKey  = f.PrimaryKey;
                item.ReadOnly    = f.IsReadOnly;
                item.AllowNull   = f.Nullable;
                item.MaxLength   = (f.Length > 0) ? f.Length : 0;
                item.Precision   = (f.Precision > 0) ? f.Precision : 0;

                item.Caption      = f.DisplayName;
                item.ViewName     = f.ViewName;
                item.HintField    = f.DescriptionName;
                item.FieldList    = f.FieldList;
                item.HeaderList   = f.HeaderList;
                item.DefaultValue = f.DefaultValue;

                list.Add(item);
            }
        }

        return(list);
    }
    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;
    }
Пример #5
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;
				}
			}
		}
	}
Пример #6
0
	/// <summary>
	/// Refresh the list of data fields using specified view name.
	/// </summary>
	private List<PXFieldSchema> RefreshFieldsList(PXDataSourceViewSchema schema, RMReportMaint graph)
	{
		PX.Data.PXFieldState[] fields = schema.GetFields();
		List<PXFieldSchema> list = new List<PXFieldSchema>();

		if (fields != null)
		{
			foreach (PX.Data.PXFieldState f in fields)
			{
				if (String.IsNullOrEmpty(f.Name) || !f.Name.StartsWith("DataSource", StringComparison.OrdinalIgnoreCase) && !f.Name.StartsWith("Request", StringComparison.OrdinalIgnoreCase) && !f.Name.StartsWith("UsrRequest", StringComparison.OrdinalIgnoreCase))
					continue;

				string dsField = f.Name;
				if (dsField.StartsWith("DataSource", StringComparison.OrdinalIgnoreCase))
					dsField = dsField.Substring(10);
				else if (f.Name.StartsWith("Request", StringComparison.OrdinalIgnoreCase))
					dsField = dsField.Substring(7);
				else
					dsField = "Usr" + dsField.Substring(10);

				PXFieldState dsState = graph.DataSourceByID.Cache.GetStateExt(null, dsField) as PXFieldState;

				if (dsState == null || !dsState.Visible) continue;

				TypeCode dataType = Type.GetTypeCode(f.DataType);
				if (dataType == TypeCode.Object) continue;

				PXFieldSchema item = new PXFieldSchema(true, f.Name, dataType);
				item.ControlType = PXSchemaGenerator.GetControlType(f);
				item.PrimaryKey = f.PrimaryKey;
				item.ReadOnly = f.IsReadOnly;
				item.AllowNull = f.Nullable;
				item.MaxLength = (f.Length > 0) ? f.Length : 0;
				item.Precision = (f.Precision > 0) ? f.Precision : 0;

				item.Caption = f.DisplayName;
				item.ViewName = f.ViewName;
				item.HintField = f.DescriptionName;
				item.FieldList = f.FieldList;
				item.HeaderList = f.HeaderList;
				item.DefaultValue = f.DefaultValue;

				list.Add(item);
			}
		}

		return list;
	}