cancel
Showing results for 
Search instead for 
Did you mean: 

datalist association control

peterzmlim
Champ in-the-making
Champ in-the-making
Dear All,

I've been trying to override the current association.ftl to datalist-association.ftl in order to create associations to nodes within the datalist. As the nodes of dl:dataList and dl:datalistItem 's cm:name are hardcoded to be the GUID of the nodes. I've been trying to override objectfinder.js to use other fields other than the cm:name as the listed items for datalist-association.ftl but it seems to be hardcoded into the ObjectRenderer_fnRenderItemName() function.

I've followed http://blog.processed.info/2010/04/custom-categories-a-custom-control-template-for-hierarchical-prop... and tried overriding onRenderCurrentValue() to temporarily force item.name = item.property["mySmiley Tongueroperty"], but there was no changes to the displayed items.

Any help or advice for this problem is definitely appreciated.
3 REPLIES 3

peterzmlim
Champ in-the-making
Champ in-the-making
I've just filled in the cm:name for the dl:dataListItem and the display on the association.ftl picker works properly

But will this affect the general functionality of the dl:dataListItem as it states here that http://wiki.alfresco.com/wiki/CMIS#Alfresco_Share_Data_Lists cm:name for dl:dataListItem can't be used for display purposes?

peterzmlim
Champ in-the-making
Champ in-the-making
So, I'm trying to override the Alfresco.ObjectRenderer.fnRenderItemName and force it to display a value of a custom property(my:custom_prop) like so within the association.ftl.

displayType is the new control-param that i've introduced to tell the control which property to derive the display names from.


    <#if field.control.params.displayType?exists>
    // place a custom function before the execution of the fnRenderItemName-function
    Alfresco.ObjectRenderer.prototype.fnRenderItemNameOriginal = Alfresco.ObjectRenderer.prototype.fnRenderItemName;
    Alfresco.ObjectRenderer.prototype.fnRenderItemName = function()
    {
       var scope = this;
   
       /**
        * Name datacell formatter
        *
        * @method renderItemName
        * @param elCell {object}
        * @param oRecord {object}
        * @param oColumn {object}
        * @param oData {object|string}
        */
       return function ObjectRenderer_renderItemName(elCell, oRecord, oColumn, oData)
       {
          var template = '';

          // Create New item cell type
          if (oRecord.getData("type") == IDENT_CREATE_NEW)
          {
             scope.createNewItemId = Alfresco.util.generateDomId();
             elCell.innerHTML = '<input id="' + scope.createNewItemId + '" type="text" class="create-new-input" tabindex="0" />';
             return;
          }

          if (oRecord.getData("isContainer") ||
              (!oRecord.getData("isContainer") && (scope.options.allowNavigationToContentChildren || oRecord.getData("type") == "cm:category")))
          {
             template += '<h3 class="item-name"><a href="#" class="theme-color-1 parent-' + scope.eventGroup + '">{name}</a></h3>';
          }
          else
          {
             if(logger.isLoggerEnabled())
             {
                logger.log("return value:" + String(oRecord.getData("properties["${field.control.params.displayType}"]"));
             }
             template += '<h3 class="item-name">' + String(oRecord.getData("properties["${field.control.params.displayType}"]")) + '</h3>';
          }

          if (!scope.options.compactMode)
          {
             template += '<div class="description">{description}</div>';
          }

          elCell.innerHTML = scope.renderItem(oRecord.getData(), 0, template);
       };
    },
    </#if>

However it didn't work and rendered the custom control association.ftl unusable. I've not overly familiar with JS or YUI, I hope that not doing anything wrong. So any help will be greatly appreciated.

Also, is the http://localhost:8080/alfresco/page/api/javascript/debugger and http://localhost:8080/share/page/api/javascript/debugger only for server side JS?

ralgozino
Champ in-the-making
Champ in-the-making
Hello Peter,

I'm trying to achieve something very similar to what you are doing. Did you make this work?

Thanks in advance!