Show data in data grid from 2 different attributes in one column based on some condition

0
I have a requirement where i need to show data in to a column where the value can come from two different attributes based on a condition. How can i do that ?
asked
3 answers
3

Hi Deependra,

the steps to achieve this in Mendix:

  1. Open the page containing the data grid or list view where you want to display the column.
  2. Select the data grid or list view and click on the Columns property in the Data Source tab.
  3. Click the Add Column button to create a new column.
  4. Set the Attribute property of the column to a placeholder attribute, such as MyAttribute.
  5. Set the Caption property to the desired column header text.
  6. In the Data Source property of the column, use a conditional expression to determine which attribute to display based on a condition. For example, if you want to display the value of Attribute1 if the Condition attribute is true, and the value of Attribute2 if the Condition attribute is false, you can use the following conditional expression:

if [MyEntity/Condition] then [MyEntity/Attribute1] else [MyEntity/Attribute2]

  1. Save the column and preview the page to see the updated data grid or list view.

By using a conditional expression in the data source of the column, you can conditionally display the value from either Attribute1 or Attribute2 based on the value of the Condition attribute.

 

 

Hope it helps!!

answered
0

Hi Deependra

Select Custom content for your column and then you can specify any dynamic information you want.

 

answered
0

Here are the steps 
1. Create column and choose custom content and don’t specify Attribute


2. Go to Column Capabilities and set all to false

 
3. In column put 2 Text Widget                       

  
4. give conditional visibility for text, in one show first attribute value, in second one show second attribute’s value

 

If you need to show association attribute, then simply put Data View widget and then choose the attribute from there. Again you may specify conditional visibility.

answered