Page 1 of 1

save columns state

Posted: Mon Jul 23, 2018 1:06 pm
by Dev_Coppelis
i need to save the states of columns like order, sorting,.....
but i found 4 events for that
stateEvents: [
        'columnmove',
        'columnresize',
        'columnhide',
        'columnshow'
    ]
but when adding new columns its state doesn't be saved so there is any solution for this ? :roll: :roll:

Re: save columns state

Posted: Mon Jul 23, 2018 1:09 pm
by Terence
If you add a new column it will probably trigger the show event, then it's state is stored.

Re: save columns state

Posted: Tue Jul 24, 2018 2:36 pm
by Dev_Coppelis
stateful: true,
    stateId: 'stateGrid',
    stateEvents: [
        'columnmove',
        'columnresize',
        'columnhide',
        'columnshow'
    ]
here are the steps to save the state of columns order.
are there any missing steps to follow ?

Re: save columns state

Posted: Tue Jul 24, 2018 3:12 pm
by Terence
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.

Re: save columns state

Posted: Wed Oct 10, 2018 2:12 pm
by vandries
hi,
it looks like
                    stateId: 'gantt-cols',
                    stateful: {
                        columns: true
                    },

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?
two Duration cols, why?
two Duration cols, why?
Screen Shot 2018-10-10 at 15.02.40.png (29.9 KiB) Viewed 9491 times
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?

Re: save columns state

Posted: Thu Oct 11, 2018 3:55 pm
by pmiklashevich
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,