Alfresco 扩展yui2-如何以正确的方式覆盖类属性

Alfresco 扩展yui2-如何以正确的方式覆盖类属性,alfresco,alfresco-share,yui2,Alfresco,Alfresco Share,Yui2,我在Alfresco Share的数据列表中添加了一些新的过滤器。现在,我希望在输入数据列表时,默认选择一个新过滤器(而不是“全部”默认过滤器) 我发现默认过滤器是在负责呈现数据列表的YUI2组件的构造函数中设置的: /** * DataGrid constructor. * * @param htmlId {String} The HTML id of the parent element * @return {Alfresco.component.DataGrid} The new Dat

我在Alfresco Share的数据列表中添加了一些新的过滤器。现在,我希望在输入数据列表时,默认选择一个新过滤器(而不是“全部”默认过滤器)

我发现默认过滤器是在负责呈现数据列表的YUI2组件的构造函数中设置的:

/**
* DataGrid constructor.
* 
* @param htmlId {String} The HTML id of the parent element
* @return {Alfresco.component.DataGrid} The new DataGrid instance
* @constructor
*/


Alfresco.component.DataGrid = function(htmlId)
   {
      Alfresco.component.DataGrid.superclass.constructor.call(this, "Alfresco.component.DataGrid", htmlId, ["button", "container", "datasource", "datatable", "paginator", "animation", "history"]);
  // Initialise prototype properties
  this.datalistMeta = {};
  this.datalistColumns = {};
  this.dataRequestFields = [];
  this.dataResponseFields = [];
  this.currentPage = 1;
  this.totalRecords = 0;
  this.showingMoreActions = false;
  this.hideMoreActionsFn = null;
  this.currentFilter =
  {
     filterId: "all",
     filterData: ""
  };
  this.selectedItems = {};
  this.afterDataGridUpdate = [];
我已经为其他目的扩展了该组件(以特殊方式呈现列等),现在我想将this.currentFilter.filterId更改为“active”(这是我的新过滤器)

这是扩展类和重写方法的方式:

 // Extend default DataList...
  YAHOO.extend(Datalist.custom.DataGrid, Alfresco.component.DataGrid,
  {
    onFilterChanged: function CustomDL_onFilterChanged(layer, args)
    {
      // Call super class method...
      Datalist.custom.DataGrid.superclass.onFilterChanged.call(this, layer,args);
  // Pop-up a message...
  Alfresco.util.PopupManager.displayMessage({
    text: "Filter Changed!"
  });
}
})); })();

但是,我还没有找到一种重写类属性的方法,例如“this.currentFilter”,我只成功地重写了方法


我查看了YUI.lang.augmentProto和YUI.lang.augmentObject,但没有真正了解如何操作。

您可以覆盖属性的初始值,但它不会有太大区别,因为它在构造函数中初始化,所以无论初始值是什么,它都会丢失

您应该重写构造函数,就像DataGrid重写其基类的构造函数一样。调用原始构造函数,然后为属性设置新值