@@ -23,8 +23,7 @@ import { childrenToProps } from "@lowcoder-ee/comps/generators/multi";
2323import { AnimationStyleType } from "@lowcoder-ee/comps/controls/styleControlConstants" ;
2424import { getBackgroundStyle } from "@lowcoder-ee/util/styleUtils" ;
2525import { 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" ;
2827import { CSS } from "@dnd-kit/utilities" ;
2928import { JSONObject } from "@lowcoder-ee/index.sdk" ;
3029
@@ -94,7 +93,7 @@ const MinHorizontalWidthContext = createContext<MinHorizontalWidthContextType>({
9493 minHorizontalWidth : '100px' ,
9594} ) ;
9695
97- const ContainerInListView = ( props : ContainerBaseProps & { itemIdx : number } ) => {
96+ const ContainerInListView = ( props : ContainerBaseProps & { itemIdx : number , enableSorting ?: boolean } ) => {
9897 const {
9998 horizontalWidth,
10099 minHorizontalWidth
@@ -104,6 +103,24 @@ const ContainerInListView = (props: ContainerBaseProps & {itemIdx: number} ) =>
104103 id : String ( props . itemIdx ) ,
105104 } ) ;
106105
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+
107124 return (
108125 < div
109126 ref = { setNodeRef }
@@ -139,6 +156,7 @@ type ListItemProps = {
139156 unMountFn ?: ( ) => void ;
140157 minHorizontalWidth ?: string ;
141158 horizontalWidth : string ;
159+ enableSorting ?: boolean ;
142160} ;
143161
144162function ListItem ( {
@@ -154,6 +172,7 @@ function ListItem({
154172 scrollContainerRef,
155173 minHeight,
156174 horizontalGridCells,
175+ enableSorting,
157176 } = props ;
158177
159178 // disable the unmount function to save user's state with pagination
@@ -195,6 +214,7 @@ function ListItem({
195214 overflow = { "hidden" }
196215 minHeight = { minHeight }
197216 enableGridLines = { true }
217+ enableSorting = { enableSorting }
198218 />
199219 </ MinHorizontalWidthContext . Provider >
200220 ) ;
@@ -248,6 +268,8 @@ export function ListView(props: Props) {
248268 } ;
249269 } , [ children . pagination , totalCount ] ) ;
250270
271+ const enableSorting = useMemo ( ( ) => children . enableSorting . getView ( ) , [ children . enableSorting ] ) ;
272+
251273 useEffect ( ( ) => {
252274 children . listData . dispatchChangeValueAction ( data ) ;
253275 } , [ JSON . stringify ( data ) ] ) ;
@@ -313,6 +335,7 @@ export function ListView(props: Props) {
313335 unMountFn = { unMountFn }
314336 horizontalWidth = { `${ 100 / noOfColumns } %` }
315337 minHorizontalWidth = { horizontal ? minHorizontalWidth : undefined }
338+ enableSorting = { enableSorting }
316339 />
317340 ) ;
318341 } ) }
@@ -365,15 +388,20 @@ export function ListView(props: Props) {
365388 $isGrid = { noOfColumns > 1 }
366389 $autoHeight = { autoHeight }
367390 >
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+ }
377405 </ ListOrientationWrapper >
378406 ) }
379407 >
0 commit comments