Hi there -
I apply initial sorting to ASPxGridView like below:
<Columns>
<dxwgv:GridViewDataTextColumn Caption="Name" FieldName="Name" SortOrder="Ascending" />
…
</Columns>
Inside the Page_Load method I call the grdiview's SaveClientLayout method which returns me the following string: "version1|page1|visible5|t0|t1|t2|t3|t4|width5|e|e|e|e|e". You see there is no information about sorting, why? After switching to the next page of the gridview the SaveClientLayout method returns "version1|page2|sort1|a0|visible5|t0|t1|t2|t3|t4|width5|e|e|e|e|e". Now there IS info about sorting here. Why is that?
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.
Wrong subject, sorry :-[
Hi Maxim,
I have created a sample project, but everything works fine. Please post here you sample project where the problem is reproduced.
And please also refer to the Filter/Sorting Parameters in URL thread.
Thanks,
Serge D
Hi Serge -
here is my sample project. To ease your research and illustrate the problem I added a piece of code that helps to get rid of the wrong behavior - yes, I believe that this behavior is unexpected and thus could be called wrong.
Thanks,
Maxim.
Hi Maxim,
This problem is related to the following part of code:
protected void Page_Load(object sender, EventArgs e) { .... report("In Page_Load: " + (!IsPostBack ? "(for the first time) " : string.Empty) + ASPxGridView1.SaveClientLayout()); ASPxGridView1.DataSource = getPersons(); ASPxGridView1.DataBind(); }
Here you are trying to save the ASPxGridView's client-side layout while it is not bound to the data source.
To resolve this problem, you should first set the data source, bind the ASPxGridView, and after that, save it's client-side layout.
protected void Page_Load(object sender, EventArgs e) { .... ASPxGridView1.DataSource = getPersons(); ASPxGridView1.DataBind(); report("In Page_Load: " + (!IsPostBack ? "(for the first time) " : string.Empty) + ASPxGridView1.SaveClientLayout()); }
I have modified your sample project. It is in the attachment.
Thanks,
Serge D
Hi Serge -
In my application I need to know initial layout of the grid without any binding. If I make a column invisible (Visible="false") and call SaveClientlayout it will return "page1|visible2|f-1|t0|width2|e|e". You see there is information about visibility of the columns. Since both sort order and visibility of the columns are their similar properties I don't understand the selectivity of your approach to saving of the grid layout. I consider this as design fault, sorry.
Thanks,
Max.
Hi Maxim,
The ASPxGridView sets column sorting in its OnLoad method (that also fires the Load event). This behavior is by design. But, the ASPxGridView.Load event fires after the Page_Load event.
So, you can save the correct (with sort directions) client layout in the page's OnLoadComplete event handler:
protected override void OnLoadComplete(EventArgs e) { base.OnLoadComplete(e); report("In Page_Load: " + (!IsPostBack ? "(for the first time) " : string.Empty) + ASPxGridView1.SaveClientLayout()); }
This also works if the ASPxGridView is not bound to a data source.
I have modified your sample. It is attached.
Thanks,
Serge D
Bad. You try to convince me to call the method only when a particular event fires. But it should work equally always. Layout is layout whether the gridview is bound or not.
Hi Maxim,
This behavior of ASPxGridView is explained by the following - the ASPxGridView doesn't set the sorting state of its columns on initialization (the ASPxGridView.Init event). The column sorting state is saved in the view state, which is restored later - in the ASPxGridView.Load event. So, if you get or set column sorting in the Page_Load event handler, which is raised before ASPxGridView.Load, this can cause unpredictable behavior.
Thanks,
Serge D