save columns state
- Dev_Coppelis
- Premium Member
- Posts: 287
- Joined: Thu Oct 05, 2017 3:38 pm
save columns state
i need to save the states of columns like order, sorting,.....
but i found 4 events for that
but when adding new columns its state doesn't be saved so there is any solution for this ?

but i found 4 events for that
Code: Select all
stateEvents: [
'columnmove',
'columnresize',
'columnhide',
'columnshow'
]


Re: save columns state
If you add a new column it will probably trigger the show event, then it's state is stored.
- Dev_Coppelis
- Premium Member
- Posts: 287
- Joined: Thu Oct 05, 2017 3:38 pm
Re: save columns state
Code: Select all
stateful: true,
stateId: 'stateGrid',
stateEvents: [
'columnmove',
'columnresize',
'columnhide',
'columnshow'
]
are there any missing steps to follow ?
Re: save columns state
I think you should follow sencha's guides about the stateful mechanism.
https://docs.sencha.com/extjs/6.2.0/cla ... g-stateful
The stateEvents are only triggered when the state is saved. More important is which properties to save.
Setting the grid to stateful should handle the sorting of your columns. When something additional needs to be done you can customise the getState and setState functions of a component. I think you will find more answers about this on Sencha's forum.
https://docs.sencha.com/extjs/6.2.0/cla ... g-stateful
The stateEvents are only triggered when the state is saved. More important is which properties to save.
Setting the grid to stateful should handle the sorting of your columns. When something additional needs to be done you can customise the getState and setState functions of a component. I think you will find more answers about this on Sencha's forum.
Re: save columns state
hi,
it looks like
properties might do the job.
but it's for only these columns that are defined in the app,
I mean by columns property.
Scenario1 (I've used fiddle app for testing from examples dir)
1. click on Duration column action icon (arrow down) - to hide it (uncheck for col list)
2. refresh;
3. it will be hidden
4. 1. click on Duration column action icon (arrow down) - to show it (check for col list)
5. refresh
6. the duration column will be visible;
Scenario2
same 1-3 steps
4. click add new column - and pick duration to show duration column
5. refresh;
6. no change - duration col is not visible
but
if we
7. click on start and check Duration column on
8. hmm now I see 2 duration options - why? imho add new column should simple activate if column already exists in the list (hidden) - but that's my 2c
I'm not sure how to make add new columns to save the state.
Sencha tells that if property is changed - then the state is saved in the "storage".
I don't see how new columns is affecting columns property - since it doesn't trigger state manger to save the state.
Shouldn't adding new column at least triggers columnchanged,columnshow event?
it looks like
Code: Select all
stateId: 'gantt-cols',
stateful: {
columns: true
},
but it's for only these columns that are defined in the app,
I mean by columns property.
Scenario1 (I've used fiddle app for testing from examples dir)
1. click on Duration column action icon (arrow down) - to hide it (uncheck for col list)
2. refresh;
3. it will be hidden
4. 1. click on Duration column action icon (arrow down) - to show it (check for col list)
5. refresh
6. the duration column will be visible;
Scenario2
same 1-3 steps
4. click add new column - and pick duration to show duration column
5. refresh;
6. no change - duration col is not visible
but
if we
7. click on start and check Duration column on
8. hmm now I see 2 duration options - why? imho add new column should simple activate if column already exists in the list (hidden) - but that's my 2c
I'm not sure how to make add new columns to save the state.
Sencha tells that if property is changed - then the state is saved in the "storage".
I don't see how new columns is affecting columns property - since it doesn't trigger state manger to save the state.
Shouldn't adding new column at least triggers columnchanged,columnshow event?
- pmiklashevich
- Core Developer
- Posts: 3390
- Joined: Fri Apr 01, 2016 11:08 am
Re: save columns state
Hello,
"Add new column" just adds a new instance of a column to the grid. You can have as many columns with the same xtype as you wish. Since default column title is the same you see 2 duration columns in the dropdown list. But in fact they are 2 different columns. "Add new column" feature shouldn't affect the process of saving the column state.
I'm afraid saving the column state is a bit out of the scope of this forum, it's better to ask for a solution on Sencha forums.
I assume you are looking at Advanced sample and using column set from the sample. To simplify your application you can try to remove 'addnewcolumn' from the columns definition.
Best regards,
"Add new column" just adds a new instance of a column to the grid. You can have as many columns with the same xtype as you wish. Since default column title is the same you see 2 duration columns in the dropdown list. But in fact they are 2 different columns. "Add new column" feature shouldn't affect the process of saving the column state.
I'm afraid saving the column state is a bit out of the scope of this forum, it's better to ask for a solution on Sencha forums.
I assume you are looking at Advanced sample and using column set from the sample. To simplify your application you can try to remove 'addnewcolumn' from the columns definition.
Best regards,
Pavel Miklashevich - Core Developer