@@ -23,8 +23,7 @@ import { childrenToProps } from "@lowcoder-ee/comps/generators/multi";
23
23
import { AnimationStyleType } from "@lowcoder-ee/comps/controls/styleControlConstants" ;
24
24
import { getBackgroundStyle } from "@lowcoder-ee/util/styleUtils" ;
25
25
import { DndContext } from "@dnd-kit/core" ;
26
- import { SortableContext , useSortable , verticalListSortingStrategy } from "@dnd-kit/sortable" ;
27
- import { restrictToVerticalAxis } from "@dnd-kit/modifiers" ;
26
+ import { SortableContext , useSortable } from "@dnd-kit/sortable" ;
28
27
import { CSS } from "@dnd-kit/utilities" ;
29
28
import { JSONObject } from "@lowcoder-ee/index.sdk" ;
30
29
@@ -94,7 +93,7 @@ const MinHorizontalWidthContext = createContext<MinHorizontalWidthContextType>({
94
93
minHorizontalWidth : '100px' ,
95
94
} ) ;
96
95
97
- const ContainerInListView = ( props : ContainerBaseProps & { itemIdx : number } ) => {
96
+ const ContainerInListView = ( props : ContainerBaseProps & { itemIdx : number , enableSorting ?: boolean } ) => {
98
97
const {
99
98
horizontalWidth,
100
99
minHorizontalWidth
@@ -104,6 +103,24 @@ const ContainerInListView = (props: ContainerBaseProps & {itemIdx: number} ) =>
104
103
id : String ( props . itemIdx ) ,
105
104
} ) ;
106
105
106
+ if ( ! props . enableSorting ) {
107
+ return (
108
+ < div
109
+ style = { {
110
+ width : horizontalWidth ,
111
+ minWidth : minHorizontalWidth || '0px' ,
112
+ } }
113
+ >
114
+ < InnerGrid
115
+ { ...props }
116
+ emptyRows = { 15 }
117
+ containerPadding = { [ 4 , 4 ] }
118
+ hintPlaceholder = { HintPlaceHolder }
119
+ />
120
+ </ div >
121
+ )
122
+ }
123
+
107
124
return (
108
125
< div
109
126
ref = { setNodeRef }
@@ -139,6 +156,7 @@ type ListItemProps = {
139
156
unMountFn ?: ( ) => void ;
140
157
minHorizontalWidth ?: string ;
141
158
horizontalWidth : string ;
159
+ enableSorting ?: boolean ;
142
160
} ;
143
161
144
162
function ListItem ( {
@@ -154,6 +172,7 @@ function ListItem({
154
172
scrollContainerRef,
155
173
minHeight,
156
174
horizontalGridCells,
175
+ enableSorting,
157
176
} = props ;
158
177
159
178
// disable the unmount function to save user's state with pagination
@@ -195,6 +214,7 @@ function ListItem({
195
214
overflow = { "hidden" }
196
215
minHeight = { minHeight }
197
216
enableGridLines = { true }
217
+ enableSorting = { enableSorting }
198
218
/>
199
219
</ MinHorizontalWidthContext . Provider >
200
220
) ;
@@ -248,6 +268,8 @@ export function ListView(props: Props) {
248
268
} ;
249
269
} , [ children . pagination , totalCount ] ) ;
250
270
271
+ const enableSorting = useMemo ( ( ) => children . enableSorting . getView ( ) , [ children . enableSorting ] ) ;
272
+
251
273
useEffect ( ( ) => {
252
274
children . listData . dispatchChangeValueAction ( data ) ;
253
275
} , [ JSON . stringify ( data ) ] ) ;
@@ -313,6 +335,7 @@ export function ListView(props: Props) {
313
335
unMountFn = { unMountFn }
314
336
horizontalWidth = { `${ 100 / noOfColumns } %` }
315
337
minHorizontalWidth = { horizontal ? minHorizontalWidth : undefined }
338
+ enableSorting = { enableSorting }
316
339
/>
317
340
) ;
318
341
} ) }
@@ -365,15 +388,20 @@ export function ListView(props: Props) {
365
388
$isGrid = { noOfColumns > 1 }
366
389
$autoHeight = { autoHeight }
367
390
>
368
- < DndContext onDragEnd = { handleDragEnd } >
369
- < SortableContext
370
- items = {
371
- _ . range ( 0 , totalCount ) . map ( ( colIdx ) => String ( colIdx ) )
372
- }
373
- >
374
- { renders }
375
- </ SortableContext >
376
- </ DndContext >
391
+ { ! enableSorting
392
+ ? renders
393
+ : (
394
+ < DndContext onDragEnd = { handleDragEnd } >
395
+ < SortableContext
396
+ items = {
397
+ _ . range ( 0 , totalCount ) . map ( ( colIdx ) => String ( colIdx ) )
398
+ }
399
+ >
400
+ { renders }
401
+ </ SortableContext >
402
+ </ DndContext >
403
+ )
404
+ }
377
405
</ ListOrientationWrapper >
378
406
) }
379
407
>
0 commit comments