Skip to content

Commit d7daf28

Browse files
expose setPage method on ListView and GridView
1 parent b0f8e67 commit d7daf28

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

client/packages/lowcoder/src/comps/comps/listViewComp/listViewComp.tsx

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import { ContextContainerComp } from "./contextContainerComp";
3737
import { ListView } from "./listView";
3838
import { listPropertyView } from "./listViewPropertyView";
3939
import { getData } from "./listViewUtils";
40+
import { withMethodExposing } from "comps/generators/withMethodExposing";
4041

4142
const childrenMap = {
4243
noOfRows: withIsLoadingMethod(NumberOrJSONObjectArrayControl), // FIXME: migrate "noOfRows" to "data"
@@ -151,11 +152,11 @@ export class ListViewImplComp extends ListViewTmpComp implements IContainer {
151152

152153
const ListViewRenderComp = withViewFn(ListViewImplComp, (comp) => <ListView comp={comp} />);
153154
const ListPropertyView = listPropertyView("listView");
154-
const ListViewPropertyComp = withPropertyViewFn(ListViewRenderComp, (comp) => {
155+
let ListViewPropertyComp = withPropertyViewFn(ListViewRenderComp, (comp) => {
155156
return <ListPropertyView comp={comp} />;
156157
});
157158

158-
export const ListViewComp = withExposingConfigs(ListViewPropertyComp, [
159+
ListViewPropertyComp = withExposingConfigs(ListViewPropertyComp, [
159160
new CompDepsConfig(
160161
"items",
161162
(comp) => ({ data: comp.itemsNode() }),
@@ -180,6 +181,22 @@ export const ListViewComp = withExposingConfigs(ListViewPropertyComp, [
180181
NameConfigHidden,
181182
]);
182183

184+
export const ListViewComp = withMethodExposing(ListViewPropertyComp, [
185+
{
186+
method: {
187+
name: "setPage",
188+
description: "",
189+
params: [{ name: "page", type: "number" }],
190+
},
191+
execute: (comp, values) => {
192+
const page = values[0] as number;
193+
if (page && page > 0) {
194+
comp.children.pagination.children.pageNo.dispatchChangeValueAction(page);
195+
}
196+
},
197+
},
198+
])
199+
183200
export function defaultListViewData(compName: string, nameGenerator: NameGenerator) {
184201
return {
185202
noOfRows:

0 commit comments

Comments
 (0)