Ticket Q454790
Visible to All Users
Duplicate

We have closed this ticket because another page addresses its subject:

GridView - Provide the capability to apply saved cookies automatically when a custom binding is used

GridView - Cookies are not applied when a custom binding is used

created 12 years ago

Hello

I'm using a GridView in Custom Binding mode and I'd like to use the SettingsCookies functionnalities. The display order of the columns works well, however I'm not able to make filteri
I assume that I must manually filter and sort the data I display and select the right rows according to the page index stored in the cookie when opening the page for the second time, but I don't know how to get the data from the cookie. Is there a way to read the data stored in the cookie?

Thanks

UPDATED:

Hello

Sorry for my previous incomplete post.
What I meant is that I've configured the gridview to use a cookie to save the column position, width, the filtering, the sorting and the paging :

C#
settings.SettingsCookies.Enabled = true; settings.SettingsCookies.CookiesID = settings.Name; settings.SettingsCookies.StoreColumnsVisiblePosition = true; settings.SettingsCookies.StoreColumnsWidth = true; settings.SettingsCookies.StoreFiltering = true; settings.SettingsCookies.StoreGroupingAndSorting = true; settings.SettingsCookies.StorePaging = true;

I'd like to note that it works well in standard databinding mode.

Here are the steps to reproduce my problem :
I start my project and display the gridview page. I change the column positions, order by a column and apply a filter.
I close the page, restart my project and display the gridview page again :
- The column positions are the same as before closing the page (it works well for this part)
- The header of the column that I chose to sort my row displays that rows are sorted. However rows are not sorted (they appear in the same order that they are when no sorting is done)
- The filter I used is neither shown nor applied

Now if I delete the cookies, and restart my project, the gridview is back to its original state.
I go on the second page and close the page. I restart my project and go on the gridview page :
- The gridview is positionned on the second page which is what I wanted. However only empty rows are displayed.

My guess is that, as I am using custom databinding, I must manually select the right page, sort and filter data when this is automatically done by the gridview in standard databinding. Therefore, I'd like to know how to read the information stored in the cookie when I load the gridview and its data to be able to select the right page and apply filters and sorting.

I've attached my project to this post. The zip file contains a backup
of the database I use. You can restore it on a SQLServer server.
You can configure the connection string to the database in the nhibernate.config file on line 13.

Thanks!

Comments (3)
DevExpress Support Team 12 years ago

    Hello Kévin,
    I would like to note that a cookie should contain information on filter criteria applied to the ASPxGridView. If this condition is not satisfied in your case, please send us a simple running project so that we can examine the issue on our side.

      Hello,
      I have updated your initial post with the detailed information you provided. We will examine your sample project and reply as soon as any results are available.
      P.S. If you want to post a new update to a ticket, please create a corresponding Comment (not a Solution):
      SC2 FAQ

      DevExpress Support Team 12 years ago

        Hi Kevin,
        I have reproduce the issue on my side. We need additional time to investigate it. We will inform you once we have any results.

        Answers approved by DevExpress Support

        created 12 years ago (modified 10 years ago)

        Hi Kevin,
        The GridView extension operates in such manner due to a custom binding operations. In this case, GridView does not apply cookies automatically. It is necessary to do this manually. Get a cookie from request, parse it and pass data to GridViewModel. We have a corresponding ticket regarding this issue GridView - Provide the capability to apply saved cookies automatically when a custom binding is used. Add this ticket to favorites to be notified of our progress.
        See Also:
        How do I access request.cookies in controller of MVC pattern(asp.net)

        Updated
        The GridView layout data cookie format is not documented. In a simple case, the cookie format is intuitive. However, in complex cases the previous suggestion will cause many difficulties. I recommend you collect GridView's state data from GridViewModel and save it on the server side. When required, update GridViewModel to restore the layout using the saved data.
        We have the How to implement custom saving in XML and restoring of ASPxGridView client layout example that demonstrates a similar solution for WebForms ASpxGridView. Although this is not an MVC example, the general idea is very similar, and I think that the example might be useful for you.

          Comments (2)
          AM AM
          Alexey Mazharenko 10 years ago

            Nikolai, where this cookie format description can be found? Now parsing is not pretty obvious.

            DevExpress Support Team 10 years ago

              Hello Alexey,

              The GridView layout data cookie format is not documented. In a simple case, the cookie format is intuitive. However, in complex cases the previous suggestion will cause many difficulties. I recommend you collect GridView's state data from GridViewModel and save it on the server side. When required, update GridViewModel to restore the layout using the saved data.
              We have the How to implement custom saving in XML and restoring of ASPxGridView client layout example that demonstrates a similar solution for WebForms ASpxGridView. Although this is not an MVC example, the general idea is very similar, and I think that the example might be useful for you.

              Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

              Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.