Making sure my extended lists always show “current” data?

前端 未结 4 1838
我寻月下人不归
我寻月下人不归 2021-01-05 03:41

When you create a Data Extender for a CME list – for instance to add a column for the Schema as in this example – it all works fine and dandy whenever you do actions that fo

4条回答
  •  花落未央
    2021-01-05 04:45

    I found how Anguilla takes care of this. When you implement a Data Extender, you are extending the information regarding the items displayed in the list, which basically means that you are extending the Data (Model) behind the item in question.

    Each Item in Tridion has its own class in the Anguilla Framework, for example a Component has its own Tridion.ContentManager.Component javascript "class".

    Having said this, and going back to the example that shows the schema name of the component, we are not actually extending the model, since that information is already available in the component. However, we need to overwrite the methods exposed on each used for displaying information in the lists the item is in, in this case a Component.

    So, when we deal with a Data Extender, if we want a full implementation of this functionality, we not only need to define the data extender:

    
        Shows extra info
    
    

    But also we need to define what's the column we are adding:

    
        
            
              
                
                
                  
                
              
              
                
              
            
          
      
    

    Once we have this, the GUI will display the column we just added: "Additional Info"

    Well, now we need to achieve the list refreshing when the item is edited/checked-out and in, etc...

    For that, we need to extend the model and implement a few methods in the Object we are extending. In this example I am extending the Page object, so whenever a page is edited, the row in the list we want to update gets refreshed, together with the rest of the cells in the table.

    To extend the model we need to define what types are we extending, in this example I am going to use the "Page" class as an example. First of all you need to define the model extension in the config file of your Editor:

    
        
          
            /Scripts/PSPage.js            
          
          
        
    
    

    and

    
      
                
      
    
    

    As you can see I am extending the Page by using the "Com.Tridion.PS.Extensions.UI.PSPage" class that is defined in the Javascript file "/Scripts/PSPage.js".

    The only method that handles the row refreshing is the following:

    Com.Tridion.PS.Extensions.UI.PSPage.prototype.getListItemXmlAttributes 
    = function PSPage$getListItemXmlAttributes(customAttributes) {
        var attribs = {};
        var p = this.properties;   
    
        if (customAttributes) {
            for (var attr in customAttributes) {
                attribs[attr] = customAttributes[attr];
            }
        }
        //This adds my custom column back when the item is updated
        attribs["ExtendedInfo"] = p.extendedInfo;
    
        return this.callBase(
            "Tridion.ContentManager.Page", 
            "getListItemXmlAttributes", 
            [attribs])
    };
    

    As you can see I am implementing the "ExtendedInfo" attribute which is the one displayed in my additional column.

    There's more than just adding a Data Extender when dealing with adding a column to our lists. I will write a post in my blog here to provide with a fully working example.

    I hope it makes sense.

提交回复
热议问题