Hide FieldViewCategory when the category shows no fields (AssetStudio)

Nik De Clercq 6 years ago in ADAM Core updated by anonymous 3 years ago 0

AssetStudio allows us to configure how the fields of a record are presented to the user. We can configure (via the .assetStudioRecordFieldView setting) how fields are grouped and we can allow a user to select a different view on a record. This is a great feature we use regularly.

We modify the .assetStudioRecordFieldView setting so that the fields are grouped logically for the user. But since a record in classification Hammers will have a different set of fields to a record in classification Screwdrivers, it is very difficult to configure the .assetStudioRecordFieldView. What will happen is that the categories specific to screwdrivers will be shown when viewing a hammer record. Since a hammer doesn't have the fieldgroup "ScrewdriverSpecifics", the FieldViewCategory that shows that group will not contain any fields. This will be the case of more than one FieldViewCategory.

Therefore it would be useful to be able to hide a FieldViewCategory when it cannot show any fields. This could be a property on FieldViewCategory. This would allow us to set or override this feature when needed.

Attached to this is a screenshot of what I mean.

Assets UX configurability fields

I've created a little dirty workaround for this. I created my own FieldGroupCategory. There I override the protected SelectFields method. When no fields can be shown by the SelectFields method, I call a method HideSections. The HideSection registers an eventhandler on the Owner.PreRender event. In the handler, I register a startup javascript that calls a function with the client ID of the Owner control. The JavaScript function will then (using jQuery) run through all fieldview table children in the Owner control. Empty tables indicate that the section shows no fields and thus they will be hidden. This is the JavaScript:

function FieldGroupCategory_HideAllEmpty(fieldViewId) {
var fldVwTbls = jQuery("#" + fieldViewId + " table.fieldview");
for (var i = 0; i < fldVwTbls.length; i++) {
var fldVwCtrl = fldVwTbls.eq(i);
if (fldVwCtrl.find("tr.fieldview-row:eq(0)").length == 0) {

It's a bit dirty and I would rather have a clean way of doing this. But for now it does the trick.