cancel
Showing results for 
Search instead for 
Did you mean: 

how to add property to view mode?

manmeet
Champ in-the-making
Champ in-the-making
I have created a new view mode (Custom View)
At present it is a trimmed down version of the Detail View Mode(removed date and size property).

Now I have sum custom defined properties.
I would like to include these too in the Custom View.
Currently I am able to see the folowing columns in the detail view:
(Name, Description, Size, Action)


I would like to see a custom column "Code ID" as below columns:
(Name, Description, Code ID, Size, Action)


How can I add these custom properties to the new view?

Any help in this regard shall be highly appreciated.

———————–
Thanks, Manmeet
5 REPLIES 5

kevinr
Star Contributor
Star Contributor
I'll explain the steps below. Note that this kind of change currently requires you to change one of our JSPs - it's obviously not ideal but it's an area of customisation we haven't tackled yet!

Firstly we need to know some information - what is the ID of your view? I'm assuming it's "custom" for now. Also, we need to know the property name for your "Code ID" value - i'm assuming it's "cm:codeid" for now. You should change the code below to reflect any changes to my assumptions.

The file you want to edit is /web-client/source/web/jsp/browse/browse.jsp and look for the section around line 400. Here you want to add another column for your view that binds to the data for your "Code ID" column. So add something like this after the Description column:

   <%– Code ID column for custom view modes –%>
   <a:column id="colcustom1" style="text-align:left" rendered="#{BrowseBean.browseViewMode == 'custom'}">
      <f:facet name="header">
         <a:sortLink id="colcustom1-sort" label="Code ID" value="codeid" styleClass="header"/>
      </f:facet>
      <h:outputText id="colcustom1-txt" value="#{r.codeid}" />
   </a:column>
This will add a new column that binds to the "cm:codeid" field on a node and will only be visible for the custom view.

Thanks,

Kevin

manmeet
Champ in-the-making
Champ in-the-making
Thank you very much Kevin. That was a bit helpful. Atleast now I can see a column with the name Code ID.

But now as assumed by you "cm:codeid" is not what I want to be displayed. I have it as "my:codeid".

I have a custom type declared as below in the web-client-custom-config.xml.
<type name="my:sop">
         <title>Standard Operating Procedure</title>
         <parent>cm:content</parent>
         <properties>
            <property name="my:codeid">
               <title>Code Id</title>
               <type>d:text</type>
            </property>
         </properties>
</type>

my:sop is inherited from the base content model (cm) using import.

I tried the below code in the browse.jsp, but to no avail.

<%– Code ID column for custom view modes –%>
   <a:column id="colcustom1" style="text-align:left" rendered="#{BrowseBean.browseViewMode == 'custom'}">
      <f:facet name="header">
         <a:sortLink id="colcustom1-sort" label="#{msg.codeid}" value="my:codeid" styleClass="header"/>
      </f:facet>
      <h:outputText id="colcustom1-txt" value="#{r.codeid}" />
   </a:column>

This helped me get a blank column of Code ID column name.
But the values of Code ID donot get populated. I think this is a problem since I have used a custom model and I cannot directly use r.codeid. What is the solution to it?

Please help in this regard.

———————-
Thanks, Manmeet

P.S. One more thing I noticed is that when I sort it on the Code Id column, it sorts correctly, its only that the values are not displayed in the column.

kevinr
Star Contributor
Star Contributor
Ahh i see, can you try this code for the outputText tag:

<h:outputText id="colcustom1-txt" value='#{r["my:codeid"]}' />
Note the use of single quotes around the 'value' attribute and the double quoted value inside it.

Thanks,

Kevin

manmeet
Champ in-the-making
Champ in-the-making
Thanks  Kevin.

It worked perfectly. Thats great!

-Manmeet

jorisvdb
Champ in-the-making
Champ in-the-making
Hello,
You don't have a custom view when search results are displayed.
Is it also possible to add or change columns in Details view of search results on Alfresco.
Kind regards,
Joris
Getting started

Tags


Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.