Skip to main content
Question

Hide column on grid with dynamic columns

  • November 10, 2022
  • 3 replies
  • 411 views

tomwhitfoot
Freshman I

I’m trying to customize a grid with dynamic columns, the number of columns are based on how many items it has on Attributes screen (CS205000).

 

Here are the samples,

 

Sample 1

 

Sample 2

 

I have the code in EntryMatrix_RowSelected event which will try to hide a column(s) based on certain condition

 

I tried using this code, but it didn’t work,

PXUIFieldAttribute.SetVisibility(sender, "Extra Small", PXUIVisibility.Invisible);
PXUIFieldAttribute.SetVisible(sender, "Extra Small", false);

 

I can’t also use this since it has no direct DAC attribute,

PXUIFieldAttribute.SetVisibility<DAC.attribute>(sender, null, PXUIVisibility.Invisible);
PXUIFieldAttribute.SetVisible<DAC.attribute>(sender, null, false);

 

Is there other way to hide column(s) maybe by name or index?

3 replies

Leonardo Justiniano
Jr Varsity II
Forum|alt.badge.img+4

Hi @tomwhitfoot 

I suggest you have a generic DAC with the supported maximum number of field attributes and then implement the control logic in your graph of how many dynamic columns are you handling on a specific context.

 

Suppose that your maximum is 10:

public class DAC : IBqlTable
{
		...

   #region Attr0
   [PXDBDecimal]
   [PXUIField(DisplayName = "Attr0", Visible = false)]
   public virtual string Attr0 { get; set; }
   public abstract class attr0 : PX.Data.BQL.BqlDecimal.Field<attr0> { }
   #endregion

        ...
        ...

   #region Attr10
   [PXDBDecimal]
   [PXUIField(DisplayName = "Attr10", Visible = false)]
   public virtual string Attr10 { get; set; }
   public abstract class attr10 : PX.Data.BQL.BqlDecimal.Field<attr10> { }
   #endregion

}

Then your logic just map them to the real attribute. This way you have access to the specific field and then applying your logic is possible:

PXUIFieldAttribute.SetVisibility<DAC.attr0>(sender, null, PXUIVisibility.Invisible);
PXUIFieldAttribute.SetVisible<DAC.attr0>(sender, null, false);

 


tomwhitfoot
Freshman I
  • Author
  • Freshman I
  • 3 replies
  • November 11, 2022

Hi @Leonardo Justiniano, thanks for the response.

 

I’m not sure if I can apply that, the number of columns is based on Attribute ID line items, it has an indefinite number, if I keep adding new lines to the attribute values, the columns in the matrix view will expand further and I can select other attribute that has their own different number of columns.

 

 

Also, the column values are in string array in the event,

 

I’m not sure if I’m handing this on the correct event.


Joe Schmucker
Captain II
Forum|alt.badge.img+2

Hi ​@tomwhitfoot. Same question for me to solve. 

This is an OLD post, but it is now my problem.  This is the only hit I had on google for this issue.  If you know of another one, please let me know!

I’m not actually trying to use a grid though.  I just need to put data in a summary table that will be used in a GI.  So my need should be a lot simpler as I don’t have to worry about the UI. 

@Leonardo Justiniano ‘s suggestion would work for me as long as the customer doesn’t go bananas adding more attributes to the Project.  Right now they have 10.  I could create 30 columns and that SHOULD cover me.  I guess if they go bananas, I could always modify the project and increase the column count.  I hate hard coding limitations, but I don’t see any other way to do it.  When creating the GI, the user will need to have a cheat sheet to manually label the fields for the description of the attribute, but that is a one time setup.

The other issue is that different Attributes have different data types.  When creating my fields in my summary table, I would need to make them ALL nvarchar and convert the values in the attributes to strings.  For a drop down list, that will be a pain as I would have to loop through all the values in the multi-select list and “flatten” them into a single value.  I’m sure Acumatica base code has some crazy complicated way they do this if you pull a record from CSAnswers into a GI, but I think that is beyond my skills.

I’m going to proceed with Leonardo’s suggestion.  Honestly, I hope this is the only option so I don’t spend 3 days on this to find out there is a new easy way.  😉

 


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings