cancel
Showing results for 
Search instead for 
Did you mean: 

Datalist grid config

vincent-kali
Star Contributor
Star Contributor
Hi,
I've deployed a custom datalist, and I'd like to apply very basic configuration to grid view like:
- set column width
- apply style to read only values
- display checkbox for boolean values


I is easy to configure this for creation/edition forms in surf config file, but what's the best way to do that for datagrid ?

Thanks,
Vincent
9 REPLIES 9

douglascrp
World-Class Innovator
World-Class Innovator
There is a special form defined as "datagrid" that allows you to configure exactly what you need.
Take a look https://github.com/Alfresco/share/blob/master/share/src/main/resources/alfresco/share-datalist-form-...

The datagrid configuration is inside a "model-type" section.
That's all you need to do.

To my understanding, this form config allow us to configure what field should be visible or not. But I can't here specify control or style to define how to display these fields… Am'I right ?

douglascrp
World-Class Innovator
World-Class Innovator
You can use the <appearance> tag and configure the controls and some more options.

For style you have to work with freemarker templates for custom controls, as described here https://wiki.alfresco.com/wiki/Forms_Examples

I can't specify any control or additional tag in this section, unlike
<config evaluator="model-type" condition="myDatalist">
or 
<config evaluator="node-type" condition="myDatalist">
, I tried but this is just ignored…..

douglascrp
World-Class Innovator
World-Class Innovator
Please, post the whole configuration file somewhere and share the link here.
Without actually seeing your code, it will be hard to help you.

vincent-kali
Star Contributor
Star Contributor
Here is the code:

The section <form id="datagrid">/<appearance> is just ignored…..


<configurations>
   <!– create form config–>     
   <config evaluator="model-type" condition="myportaldatalist:customercontact">
      <forms>
         <form>
            <!– create form config–>
            <field-visibility>
               <show id="myportaldatalist:contactFirstName"/>
               <show id="myportaldatalist:contactLastName"/>
               <show id="myportaldatalist:contactEmail"/>
               <show id="myportaldatalist:contactCompany"/>
               <show id="myportaldatalist:emailenabled"/>
               <show id="myportaldatalist:attacheddocument"/>
               <show id="myportaldatalist:resetpasswordrequested"/>
               <show id="myportaldatalist:contactNotes"/>
            </field-visibility>
            <create-form template="../data-lists/forms/dataitem.ftl" />
            <appearance>
               <field id="myportaldatalist:contactNotes">
                  <control template="/org/alfresco/components/form/controls/textarea.ftl" />
               </field>
               <field id="myportaldatalist:emailenabled">
                  <control template="/org/alfresco/components/form/controls/checkbox.ftl" />
               </field>
               <field id="myportaldatalist:attacheddocument">
                  <control template="/org/alfresco/components/form/controls/checkbox.ftl" />
               </field>           
               <field id="myportaldatalist:resetpasswordrequested">
                  <control template="/org/alfresco/components/form/controls/checkbox.ftl" />
               </field>           
            </appearance>
         </form>   
         <form id="datagrid">
            <field-visibility>
               <show id="myportaldatalist:contactFirstName"/>
               <show id="myportaldatalist:contactLastName"/>
               <show id="myportaldatalist:contactEmail"/>
               <show id="myportaldatalist:contactCompany"/>
               <show id="myportaldatalist:contactUserName"/>
               <show id="myportaldatalist:emailenabled"/>
               <show id="myportaldatalist:attacheddocument"/>
               <show id="myportaldatalist:resetpasswordrequested"/>
               <show id="myportaldatalist:contactNotes"/>
            </field-visibility>
            <!– This section seems to be ignored….–>
            <appearance>
               <field id="myportaldatalist:emailenabled">
                  <control template="/org/alfresco/components/form/controls/checkbox.ftl" />
               </field>
               <field id="myportaldatalist:attacheddocument">
                  <control template="/org/alfresco/components/form/controls/checkbox.ftl" />
               </field>           
               <field id="myportaldatalist:resetpasswordrequested">
                  <control template="/org/alfresco/components/form/controls/checkbox.ftl" />
               </field>           
            </appearance>
         </form>
      </forms>
   </config>
   <!– edit form config–>
   <config evaluator="node-type" condition="myportaldatalist:customercontact">
      <forms>
         <form>
            <field-visibility>
               <show id="myportaldatalist:contactFirstName"/>
               <show id="myportaldatalist:contactLastName"/>
               <show id="myportaldatalist:contactEmail"/>
               <show id="myportaldatalist:contactCompany"/>
               <show id="myportaldatalist:contactUserName"/>
               <show id="myportaldatalist:emailenabled"/>
               <show id="myportaldatalist:attacheddocument"/>
               <show id="myportaldatalist:resetpasswordrequested"/>
               <show id="myportaldatalist:contactNotes"/>
            </field-visibility>
            <edit-form template="../data-lists/forms/dataitem.ftl" />
            <appearance>
               <field id="myportaldatalist:contactUserName" read-only="true">
                  <control template="/org/alfresco/components/form/controls/readonly.ftl" />
               </field>
               <field id="myportaldatalist:contactNotes">
                  <control template="/org/alfresco/components/form/controls/textarea.ftl" />
               </field>
               <field id="myportaldatalist:emailenabled">
                  <control template="/org/alfresco/components/form/controls/checkbox.ftl" />
               </field>
               <field id="myportaldatalist:attacheddocument">
                  <control template="/org/alfresco/components/form/controls/checkbox.ftl" />
               </field>
               <field id="myportaldatalist:resetpasswordrequested">
                  <control template="/org/alfresco/components/form/controls/checkbox.ftl" />
               </field>           
            </appearance>
         </form>         
      </forms>
   </config>
</configurations>

douglascrp
World-Class Innovator
World-Class Innovator
I think Steven is right.
You won't be able to configure the appearance of the datagrid columns using that config.
Now I understand what you are trying to do.
The datagrid section will only let you define the order of the fields, but not the appearance.

About the datagrid customization, you can try this addon's source code to have some ideas https://github.com/ITDSystems/alvex-datagrid

steven_okennedy
Star Contributor
Star Contributor
Hi Vincent,

As far as I'm aware the DataList screen requests the form content based on the id="datalist" form type, but doesn't process it as a real form.  It only extracts the <field-visibility> elements and doesn't use the <appearance> tags to control the output on screen - it's effectively using specific table cell renderers, not dynamic form controls unfortunately.

To do what you need you're likely to have to down the route of some Share extension modules to allow the use of custom renderers (or even better, renderers that use the appearance tags to control things) - but that may be a large customisation to the page.

If I get a chance I'll have a look at how the table is rendered, it's been a while since I opened up the code there

Regards

Steven

Thanks your replies. I'll try to find a solution and post results (if sucess)