lots of updates
This commit is contained in:
parent
02c48e6108
commit
8ed083fce1
14 changed files with 730 additions and 83 deletions
|
|
@ -216,8 +216,8 @@
|
|||
<DataTable
|
||||
ref="dataTableRef"
|
||||
:value="data"
|
||||
:rowsPerPageOptions="[5, 10, 20, 50]"
|
||||
:paginator="true"
|
||||
:rowsPerPageOptions="rowsPerPageOptions"
|
||||
:paginator="paginator"
|
||||
:rows="currentRows"
|
||||
:first="currentFirst"
|
||||
:lazy="lazy"
|
||||
|
|
@ -230,7 +230,7 @@
|
|||
filterDisplay="none"
|
||||
v-model:filters="filterRef"
|
||||
scrollable
|
||||
scrollHeight="70vh"
|
||||
:scrollHeight="scrollHeight"
|
||||
v-model:selection="selectedRows"
|
||||
selectionMode="multiple"
|
||||
metaKeySelection="true"
|
||||
|
|
@ -398,6 +398,19 @@ const props = defineProps({
|
|||
type: Array,
|
||||
required: true,
|
||||
},
|
||||
// Pagination control
|
||||
paginator: {
|
||||
type: Boolean,
|
||||
default: true,
|
||||
},
|
||||
rows: {
|
||||
type: Number,
|
||||
default: 10,
|
||||
},
|
||||
rowsPerPageOptions: {
|
||||
type: Array,
|
||||
default: () => [5, 10, 20, 50],
|
||||
},
|
||||
filters: {
|
||||
type: Object,
|
||||
default: () => ({
|
||||
|
|
@ -424,6 +437,10 @@ const props = defineProps({
|
|||
type: String,
|
||||
default: "pi pi-spinner pi-spin",
|
||||
},
|
||||
scrollHeight: {
|
||||
type: String,
|
||||
default: "70vh",
|
||||
},
|
||||
// Auto-connect to global loading store
|
||||
useGlobalLoading: {
|
||||
type: Boolean,
|
||||
|
|
@ -479,15 +496,18 @@ const loading = computed(() => {
|
|||
|
||||
// Get current rows per page from pagination store or default
|
||||
const currentRows = computed(() => {
|
||||
if (!props.paginator) {
|
||||
return props.data?.length || 0;
|
||||
}
|
||||
if (props.lazy) {
|
||||
return paginationStore.getTablePagination(props.tableName).rows;
|
||||
}
|
||||
return 10; // Default for non-lazy tables
|
||||
return props.rows || 10; // Default for non-lazy tables
|
||||
});
|
||||
|
||||
// Get current first index for pagination synchronization
|
||||
const currentFirst = computed(() => {
|
||||
if (props.lazy) {
|
||||
if (props.lazy && props.paginator) {
|
||||
return paginationStore.getTablePagination(props.tableName).first;
|
||||
}
|
||||
return currentPageState.value.first;
|
||||
|
|
@ -497,7 +517,7 @@ const currentFirst = computed(() => {
|
|||
onMounted(() => {
|
||||
filtersStore.initializeTableFilters(props.tableName, props.columns);
|
||||
filtersStore.initializeTableSorting(props.tableName);
|
||||
if (props.lazy) {
|
||||
if (props.lazy && props.paginator) {
|
||||
paginationStore.initializeTablePagination(props.tableName, {
|
||||
rows: 10,
|
||||
totalRecords: props.totalRecords,
|
||||
|
|
@ -532,7 +552,7 @@ const filterRef = computed({
|
|||
watch(
|
||||
() => props.totalRecords,
|
||||
(newTotal) => {
|
||||
if (props.lazy && newTotal !== undefined) {
|
||||
if (props.lazy && props.paginator && newTotal !== undefined) {
|
||||
// Force reactivity update for page controls
|
||||
selectedPageJump.value = "";
|
||||
}
|
||||
|
|
@ -603,6 +623,9 @@ const hasFilterChanges = computed(() => {
|
|||
});
|
||||
|
||||
const totalPages = computed(() => {
|
||||
if (!props.paginator) {
|
||||
return 1;
|
||||
}
|
||||
if (props.lazy) {
|
||||
return paginationStore.getTotalPages(props.tableName);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue