1. #1
    Sencha User
    Join Date
    May 2013
    Location
    Hyderabad, India
    Posts
    16
    Answers
    1
    Vote Rating
    1
    hmnth1 is on a distinguished road

      0  

    Default Answered: How to save grid columns show up?

    Answered: How to save grid columns show up?


    While showing the grid we are having the option to show/hide the columns which we want to view.

    If i unchecked a specific column it is is not showing in the grid. Upto this ok.
    If i refresh the grid again the column is showing up.

    But i need like this,

    1. If i unchecked a particular column then it should not be visible in future to the user who did that one.
    2. That column should be visible for other users other than the first user who unchecked a column.
    3. If the user wants to show that in the grid then user can check that column and it should be shown.

  2. this can be done with cookies. read some basis tutorial on cookies and you will find out how to use them. there are functions available to read, set and delete cookies in these tutorials.

    other than this, you can use Ext.state.Stateful by setting stateful to true and assigning a stateId to the component. This works for height, width etc. see if it also works for column hide/show states. First try it with stateful and if it doesnt store this info, then you can do it yourself with cookies.

  3. #2
    Touch Premium Member
    Join Date
    Jun 2011
    Posts
    1,099
    Answers
    113
    Vote Rating
    96
    Farish is a glorious beacon of light Farish is a glorious beacon of light Farish is a glorious beacon of light Farish is a glorious beacon of light Farish is a glorious beacon of light

      2  

    Default


    this can be done with cookies. read some basis tutorial on cookies and you will find out how to use them. there are functions available to read, set and delete cookies in these tutorials.

    other than this, you can use Ext.state.Stateful by setting stateful to true and assigning a stateId to the component. This works for height, width etc. see if it also works for column hide/show states. First try it with stateful and if it doesnt store this info, then you can do it yourself with cookies.

  4. #3
    Sencha User
    Join Date
    May 2013
    Location
    Hyderabad, India
    Posts
    16
    Answers
    1
    Vote Rating
    1
    hmnth1 is on a distinguished road

      0  

    Default


    Yes i am doing the same thing as you specified.
    like in my grid

    i am specifying stateId and stateful :true and i am creating cookies like this

    Ext.state.Manager.setProvider(Ext.create('Ext.state.CookieProvider'));

    But if grid reloads data is not showed up correctly , data is replicating for some of the columns.

    And if i click refresh icon there again the hidden column is appearing and data is appearing fine


    Also can you please suggest where to intialize that cookieprovider line while developing a grid with some example code

  5. #4
    Touch Premium Member
    Join Date
    Jun 2011
    Posts
    1,099
    Answers
    113
    Vote Rating
    96
    Farish is a glorious beacon of light Farish is a glorious beacon of light Farish is a glorious beacon of light Farish is a glorious beacon of light Farish is a glorious beacon of light

      1  

    Default


    take a look at this example and view its source (right click -> View Page Source):

    http://docs.sencha.com/extjs/4.2.2/e...ate/state.html

  6. #5
    Sencha User
    Join Date
    May 2013
    Location
    Hyderabad, India
    Posts
    16
    Answers
    1
    Vote Rating
    1
    hmnth1 is on a distinguished road

      0  

    Default


    The same example which i was looked into and implemented.

    But i am using MVC architecture in my application. So i need exactly that where the below line should be kept.

    Ext.state.Manager.setProvider(Ext.create('Ext.state.CookieProvider'));

  7. #6
    Touch Premium Member
    Join Date
    Jun 2011
    Posts
    1,099
    Answers
    113
    Vote Rating
    96
    Farish is a glorious beacon of light Farish is a glorious beacon of light Farish is a glorious beacon of light Farish is a glorious beacon of light Farish is a glorious beacon of light

      1  

    Default


    In the launch function of your application:

    http://docs.sencha.com/extjs/4.2.1/#...-method-launch

  8. #7
    Sencha User
    Join Date
    May 2013
    Location
    Hyderabad, India
    Posts
    16
    Answers
    1
    Vote Rating
    1
    hmnth1 is on a distinguished road

      0  

    Default


    Thank you very much
    I am just doing like that one.

    I will test and let you know whether it is resolved or not

  9. #8
    Sencha User
    Join Date
    May 2013
    Location
    Hyderabad, India
    Posts
    16
    Answers
    1
    Vote Rating
    1
    hmnth1 is on a distinguished road

      0  

    Default


    Yes it is working. Thank you again

  10. #9
    Sencha User
    Join Date
    May 2013
    Location
    Hyderabad, India
    Posts
    16
    Answers
    1
    Vote Rating
    1
    hmnth1 is on a distinguished road

      0  

    Default


    Hi Farish,
    Extra problems coming with this cookie manager. The grid is behaving abnormally. The columns are reordered by its own. I dont know why?
    And
    I want only the cookie part to remember is the show and hide of columns not the sort order etc.,

    Is there any way to save the show, hide of columns in database and show up only those fields next time.

    I think in the "model" also we have to modify that only the fields to be displayed that are saved in the database which are under category to be shown.

Thread Participants: 1