2013-05-30 5 views
0

Alfresco 공유의 데이터 목록에 새 필터를 추가했습니다. 이제 내 데이터리스트를 입력 할 때 새 필터 중 하나를 기본 필터 ("모든"기본 필터 대신)로 선택하겠습니다. 나는 이미 열을 렌더링 다른 목적으로이 구성 요소를 (확장 한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 = []; 

:

나는 데이터 목록을 렌더링하기위한 기본 필터가 YUI2 구성 요소 책임의 생성자에서 설정되어있는 것을 발견 특별한 방법 등) 지금은 this.currentFilter.filterId를 "active"(내 새 필터)로 변경하려고합니다.

이것은 당신이 클래스를 확장하는 방법과 방법 오버라이드 (override) :

// 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를 실제로 수행하는 방법을 모른 채 살펴 보았습니다.

답변

1

속성의 초기 값을 재정의 할 수 있지만 어쨌든 초기 값이 무엇이든 관계없이 생성자에서 초기화되기 때문에 차이가별로 없기 때문에 손실 될 수 있습니다.

DataGrid가 기본 클래스의 생성자를 재정의하는 것과 같은 방법으로 생성자를 재정의해야합니다. 원래 생성자를 호출 한 다음 속성에 새 값을 설정합니다.