주요 콘텐츠로 건너뛰기

open-filter

설명

필드에 대한 필터가 활성화될 때 발생합니다

사용법

"open-filter": ({
id: string | null,
area?: "values" | "rows" | "columns"
}) => boolean | void;

매개변수

해당 action의 callback은 다음 매개변수를 받습니다:

  • area - 필드가 적용되는 영역("rows", "columns", "values")
  • id - 필드의 id. null 값을 가진 단일 id 인수가 전달되면 필터가 닫힙니다.
정보

내부 이벤트를 처리하려면 Event Bus 메서드를 사용할 수 있습니다.

반환값

함수는 boolean 값 또는 void를 반환할 수 있습니다. false를 반환하면 해당 이벤트 동작이 중단됩니다.

예제

아래 예제는 필터 박스를 닫을 때 Configuration 패널을 숨기는 방법을 보여줍니다:

const table = new pivot.Pivot("#root", {
fields,
data: dataset,
config: {
rows: ["studio", "genre"],
columns: [],
values: [
{
field: "title",
method: "count"
},
{
field: "score",
method: "max"
}
]
}
});

table.api.on("open-filter", (ev) => {
if(!ev.id) {
table.api.exec("show-config-panel", {
mode: false
});
}
});

다음 예제에서는 필터가 활성화된 필드의 id를 콘솔에 출력합니다:

const table = new pivot.Pivot("#root", {
fields,
data,
config: {
rows: ["studio", "genre"],
columns: [],
values: [
{
field: "title",
method: "count"
},
{
field: "score",
method: "max"
}
]
}
});

table.api.on("open-filter", (ev) => {
console.log("The field id for which filter is activated:", ev.id);
});