Show cool things you have done with our products

Post by Dev_Coppelis »

i need to save the states of columns like order, sorting,.....
but i found 4 events for that
stateEvents: [
but when adding new columns its state doesn't be saved so there is any solution for this ? :roll: :roll:

Post by Terence »

If you add a new column it will probably trigger the show event, then it's state is stored.

Post by Dev_Coppelis »

stateful: true,
    stateId: 'stateGrid',
    stateEvents: [
here are the steps to save the state of columns order.
are there any missing steps to follow ?

Post by Terence »

I think you should follow sencha's guides about the stateful mechanism. ... 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.

Post by vandries »

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;

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
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.98 KiB) Viewed 7424 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?

Post by pmiklashevich »


"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,

Pavlo Miklashevych
Sr. Frontend Developer

Post Reply