确保我的扩展列表始终显示“当前"数据? [英] Making sure my extended lists always show "current" data?

查看:24
本文介绍了确保我的扩展列表始终显示“当前"数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当您为 CME 列表创建数据扩展器时 - 例如为架构添加一列,如 这个例子 - 每当你执行强制列表重新加载的操作时,它都能正常工作.

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 force a List reload.

但是,某些操作不会强制重新加载列表(例如编辑文件夹中的组件,然后保存并关闭),并且看起来 Anguilla 正在加载使用不同机制更改的项目的数据,该机制仅加载相关项目的数据(这是有道理的).

However, some actions don’t force a list reload (like editing a component in a folder, then saving & closing) and it looks like Anguilla is loading the data for the item that changed using a different mechanism that loads only the data for the item in question (which makes sense).

如果我希望我的扩展列表视图正常运行,并且在给定项目更改时(而不是仅在重新加载列表视图时)加载我的附加属性,我还需要做什么?

If I would want my extended list view to behave properly and also load my additional attributes whenever a given item changes (instead of only when the list view is reloaded) what else do I need to do?

推荐答案

我发现 Anguilla 如何解决这个问题.当您实现数据扩展器时,您正在扩展有关列表中显示的项目的信息,这基本上意味着您正在扩展相关项目后面的数据(模型).

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.

Tridion 中的每个项目在 Anguilla 框架中都有自己的类,例如一个组件有自己的 Tridion.ContentManager.Component javascript类".

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.

所以,当我们处理一个 Data Extender 时,如果我们想要一个完整的实现这个功能,我们不仅需要定义 Data Extender:

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:

<ext:dataextender 
    name="IntelligentDataExtender" 
    type="Com.Tridion.PS.Extensions.IntelligentDataExtender,PS.GUI.Extensions">
    <ext:description>Shows extra info</ext:description>
</ext:dataextender>

但我们还需要定义我们要添加的列是什么:

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

<ext:lists>
    <ext:add>
        <ext:extension name="IntelligentColumnExtender"   
                       assignid="IntelligentDataColumnExtender">
          <ext:listDefinition>
            <ext:selectornamespaces/>
            <ext:columns>
              <column 
                  xmlns="http://www.sdltridion.com/2009/GUI/extensions/List"
                  id="IntelligentData" 
                  type="data"  
                  title="Additional Info" 
                  selector="@ExtendedInfo" 
                  translate="String"/>
            </ext:columns>
          </ext:listDefinition>
          <ext:apply>
            <ext:view name="DashboardView" />
          </ext:apply>
        </ext:extension>
      </ext:add>
  </ext:lists>

一旦我们有了这个,GUI 将显示我们刚刚添加的列:附加信息"

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...

为此,我们需要扩展模型并在我们扩展的对象中实现一些方法.在此示例中,我扩展了 Page 对象,因此每当编辑页面时,我们要更新的列表中的行以及表中的其余单元格都会刷新.

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.

要扩展模型,我们需要定义要扩展的类型,在本示例中,我将使用Page"类作为示例.首先,您需要在编辑器的配置文件中定义模型扩展:

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:

<cfg:group name="Com.Tridion.PS.Extensions.UI.Model"
     merger="Tridion.Web.UI.Core.Configuration.Resources.DomainModelProcessor" 
     merge="always">
    <cfg:domainmodel name="Com.Tridion.PS.Extensions.UI.Model">
      <cfg:fileset>
        <cfg:file type="script">/Scripts/PSPage.js</cfg:file>            
      </cfg:fileset>
      <cfg:services />
    </cfg:domainmodel>
</cfg:group>

<ext:modelextensions>
  <cfg:itemtypes>
    <cfg:itemtype id="tcm:64" implementation="Com.Tridion.PS.Extensions.UI.PSPage" />        
  </cfg:itemtypes>
</ext:modelextensions>

如您所见,我使用 JavaScript 文件/Scripts/PSPage.js"中定义的Com.Tridion.PS.Extensions.UI.PSPage"类来扩展页面.

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])
};

如您所见,我正在实施ExtendedInfo"属性,该属性显示在我的附加列中.

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.

我希望这是有道理的.

这篇关于确保我的扩展列表始终显示“当前"数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆