태그 보관물: reset-filter

reset-filter

magento 사용자 정의 모듈에서 컬렉션을로드 할 때 필터를 재설정하는 방법 아래는 imei를

관리 그리드에 ‘imei’의 검색 결과를 표시하기 위해 백엔드에서 사용자 정의 모듈을 만들었습니다.

1) 아래는 imei를 검색하는 홈페이지입니다.
여기에 이미지 설명을 입력하십시오

2) 검색 결과 페이지.

3) 검색 후 imei 텍스트 필드 검색에 23과 같은 값을 입력하십시오.

4) 이제 홈페이지로 돌아가서 다른 값을 검색합니다.

5)하지만 이제는 레코드를 찾을 수 없지만 해당 특정 검색에 대한 레코드가 있습니다.

이 일이 발생하기 때문에 컬렉션을로드 할 때 필터를 재설정해야합니다.



답변

사용자 정의 모듈에서 grid.php 파일을 편집하십시오.

기본적으로,

public function __construct()
{
 parent::__construct();
 $this->setId('productsGrid');
 // This is the primary key of the database
 $this->setDefaultSort('id');
 $this->setDefaultDir('ASC');
 $this->setSaveParametersInSession(true);
 $this->setUseAjax(true);
}

코드를 다음과 같이 변경하십시오.

public function __construct()
{
    parent::__construct();
    $this->setId('productsGrid');
    // This is the primary key of the database
    $this->setDefaultSort('id');
    $this->setDefaultDir('ASC');
    $this->setUseAjax(true);
}

답변

필터 값 base64_encoded를 해당 컨트롤러에 전달해야합니다. 필터 값은에 의해 처리됩니다 Mage_Adminhtml_Block_Widget_Grid::_prepareCollection().

값은 먼저 디코딩 된 다음 세션에서 설정됩니다.

    $data = $this->helper('adminhtml')->prepareFilterString($filter);
    $this->_setFilterValues($data);

grid.js 객체를 인스턴스화하기 시작합니다. 메소드를 살펴 보자 doFilter()하고 resetFilter().


답변