DataTable state persistence

UI Components for Vue
Post Reply
urbik
Posts: 4
Joined: 08 Oct 2020, 10:58

08 Oct 2020, 11:10

Hi, i'm trying to use DataTable state session/localStorage feature, but I can't get it to work. I'm planning on using it on larger DataTable but now I'm trying it with minimal code possible but still it's not working.
Can you help me, please? It would be much nicer to have things like columns reordering persisting than just the filters if I would do it custom way.

Code: Select all

	<DataTable :value="tests" :filters="filtersTest"
                    stateStorage="session" stateKey="dt-state-demo-session">
            <Column field="name">
                <template #filter>
                    <InputText type="text" v-model="filtersTest['name']" class="p-column-filter" placeholder="Hledat"/>
                </template>
            </Column>
            <Column field="id">
            </Column>
        </DataTable>

Code: Select all

export default {
  data() {
    return {
    	tests: [],
    	filtersTest: {}
    }
  },
  mounted() {
  	this.tests = [
            {
                name: "test",
                id: 123
            },
            {
                name: "test 2",
                id: 312
            },
            {
                name: "tester",
                id: 132
            },
        ]
  }
}

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

10 Oct 2020, 15:53

To begin with, do you experience issues with the live demo?

https://primefaces.org/primevue/showcas ... able/state

urbik
Posts: 4
Joined: 08 Oct 2020, 10:58

12 Oct 2020, 11:41

No, I do not, demo works just fine.

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

12 Oct 2020, 21:47

Ok, what are your PrimeVue and Vue versions?

urbik
Posts: 4
Joined: 08 Oct 2020, 10:58

14 Oct 2020, 18:52

"primevue": "2.0.5"
"vue": "2.6.11"

urbik
Posts: 4
Joined: 08 Oct 2020, 10:58

16 Oct 2020, 13:38

I just tried using PrimeVue version 2.2.0 and newer and older Vue version (2.5.22 and 2.6.12) and the only result was that my DataTable seized to show any rows even though they were present. But this only happened to my production-ready datatable, the minimalist testing datatable did not react at all.

mert.sincan
Posts: 5281
Joined: 29 Jun 2013, 12:38

13 Nov 2020, 23:10

Hi,

Thanks a lot for the update! Firstly, could you please check the value of filtersTest variable after dataTable is filtered? Then could you please check the value of dt-state-demo-session in session storage on the browser? And then, could you please try :filters.sync="filtersTest"?

Best Regards,


Post Reply

Return to “PrimeVue”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 10 guests