Skip to content

Commit d0aea64

Browse files
committed
fix crash in lazy pagination in demo
1 parent fe7e490 commit d0aea64

File tree

1 file changed

+3
-3
lines changed
  • demo-common/src/commonMain/kotlin/com/seanproctor/datatable/demo

1 file changed

+3
-3
lines changed

demo-common/src/commonMain/kotlin/com/seanproctor/datatable/demo/App.kt

+3-3
Original file line numberDiff line numberDiff line change
@@ -104,14 +104,14 @@ fun App(onRowClick: (Int) -> Unit) {
104104
} else {
105105
LazyPaginatedDataTable(
106106
columns = columns,
107-
state = rememberPaginatedDataTableState(5),
107+
state = rememberPaginatedDataTableState(initialPageSize = 5, initialCount = sortedData.size),
108108
sortColumnIndex = sortColumnIndex,
109109
sortAscending = sortAscending,
110110
modifier = Modifier.fillMaxWidth().padding(16.dp),
111111
logger = { println(it) },
112112
fetchPage = { state ->
113113
val fromIndex = state.pageIndex * state.pageSize
114-
val toIndex = min(fromIndex + state.pageSize, state.count-1)
114+
val toIndex = min(fromIndex + state.pageSize, sortedData.size)
115115
val subset = sortedData.subList(fromIndex, toIndex)
116116
subset.forEachIndexed { index, rowData ->
117117
row {
@@ -160,4 +160,4 @@ fun DataTableScope.generateTable(data: List<DemoData>, onRowClick: (Int) -> Unit
160160
}
161161
}
162162

163-
data class DemoData(val value: Float, val text: String)
163+
data class DemoData(val value: Float, val text: String)

0 commit comments

Comments
 (0)