cancel
Showing results for 
Search instead for 
Did you mean: 

add extra column to task datalist

krups
Champ in-the-making
Champ in-the-making
Hello

I am really new to Alfresco.
I want to add some fields(column) to existing dl:task in datalist. How can I do this?
Also I want to know that is it possible to add Number field as auto generated?

Thank you
KR
5 REPLIES 5

jonash
Champ in-the-making
Champ in-the-making
Hi,

Data lists in Share are defined in a content model by creating content types that inherit from dl:dataListItem. You can find the default data list content types in <tomcat_home>webapps/alfresco/WEB-INF/classes/alfresco/model/datalistModel.xml.

To add a column you need to add a property to the content type that corresponds to the data list you want to extend. I would recommend not to modify the default dl:task type but to extend it with a custom type and add the new property there:


<type name="foo:customTask">
  <title>Task List (Custom)</title>
   <parent>dl:task</parent>
  <properties>
    <property name="foo:numberField">
      <title>Number field</title>
      <type>d:int</type>
      …
  </properties>
</type>


To display the new field in Share you also have to configure a form for the new content type. You can find examples in webapps/share/WEB-INF/classes/alfresco/share-datalist-form-config.xml

krups
Champ in-the-making
Champ in-the-making
Thank you Jonash.
Could you please do me one more favour?
I want to create
- auto generated column
- Colour in status column
- link to alfresco sites
in datalist. do you know how to achive that?

for example,
When i create new dataitem in datalist then it should generate auto number and generate status colour like
No title status                                                         link
1   abc   red-colour(should display colour not text)     abc
2   xyz   greeen-colour                                             xyz
etc.

KR

jonash
Champ in-the-making
Champ in-the-making
Hi krups,

1) For the auto-generated column: if you just want a default value you can add this to the content model:


<properties>
    <property name="foo:numberField">
      <title>Number field</title>
      <type>d:int</type>
      <default>123</default>
      …


If you want something more complex like set a value based on other fields you could create a behaviour. This lets you execute code triggered by events in the repository, for example on the creation of a new node or an update of the properties. See http://ecmarchitect.com/images/articles/alfresco-behavior/behavior-article.pdf for a good tutorial on behaviors.

2) For colored fields and links you should look into creating a custom control. In the appearance section of the forms configuration you can configure which Freemarker template is used to render the field.

Example:

<field id="cm:title">
  <control template="/org/alfresco/components/form/controls/textfield.ftl" />
</field>

You can find the out of the box controls in webapps/share/WEB-INF/classes/alfresco/site-webscripts/org/alfresco/components/form/controls/

krups
Champ in-the-making
Champ in-the-making
Hi Jonash,

Thank you once again.
I tried <default>123</default> with my "NO" field but it didn't work.Its throwing faliure - NOT FOUND error when i restarted server.
Actually I am really new to Alfresco. what i really want is to add custom field which is autogenerated number.I mean when I create new dataitem (for ex. 1st) it should generate 1 and when I save it I should appear under my new custom field on datagrid as below.
No title  desc
1   abc   xyz

and after then if I create new dataitem again (2nd) and save it then It should be like
No title desc
1   abc  xyz
2   opq  def

Could you please give me some idea what to do?

Thanks



FYI: I am using alfresco-4.0.a

jonash
Champ in-the-making
Champ in-the-making
Can you give the full error message/strack trace you get when defining a default value in your content model?

One way to implement the auto-generated number is with a behaviour. See the tutorial I linked to above for an example. You can create a behaviour that is triggered by the creation of node of the custom data list item type that sets the property to the correct value.