Hiding a Column Without Removing From a View in Model-Driven App

Sometimes, there is a requirement to hide a column from a view (main grid or subgrid view) even though the column is required for the view to be functional. Since the column is still required, it cannot be removed using the modern view designer.

One of the examples is to hide the column that is used for sorting because it is showing up as a subtitle in the lookup dropdown because it is the 2nd column of the lookup view. Kailash Ramachandran has blogged about the solution for such a problem by removing the column only in the LayoutXml with the “Select Columns” option in the View Designer tool in XrmToolBox.


Another requirement with a similar problem is to hide the Path column in the associated view of the SharePoint documents in the model-driven app (as commented over here).


If the Path (relativelocation) column is removed from the view in the view designer, the grid control is not able to render anymore.


As in the solution above, I tried to load the Document Associated Grid with the View Designer tool in XrmToolBox but I was getting NullReferenceException error and was unable to save the view. Since the tool was last updated in 2016, there might be some issues with the new properties introduced in the later version of the view schema.


Since View Designer tool is not working well with Document Associated Grid, the only solution is to update the LayoutXml manually. To do so, create a new solution, add the view into the solution, export and extract the solution.zip file and edit the customizations.xml. In the XML file, find the cell element for Path (with name="relativelocation") cell, replace the width attribute with (ishidden="1") as in the screenshot below (or remove the whole element).


That will hide the column from the view but it will still remain in the <fetchxml> so that the grid control will still be functional.

Comments

  1. I am afraid this may be unsupported, could you confirm? Thanks in advance..

    ReplyDelete
    Replies
    1. Based on the following MS Learn documentation, editing saved queries is a supported task.
      "Definitions of views for tables are included in the customizations.xml file and may be manually edited."
      https://learn.microsoft.com/en-us/power-apps/developer/model-driven-apps/when-edit-customization-file?source=recommendations&WT.mc_id=DX-MVP-5003873#supported-tasks

      "ishidden" attribute of the cell element for the layoutxml is also documented in the Customization solutions file schema, so I would say this is a supported customization.
      https://learn.microsoft.com/en-us/power-apps/developer/data-platform/customization-solutions-file-schema?WT.mc_id=DX-MVP-5003873

      Delete
    2. Thank you for your inputs on this..nice one..

      Delete

Post a Comment

Popular Posts