Ticket T488468
Visible to All Users

ASPxGridView - How to remove the fixed width on the server side

created 8 years ago

[DevExpress Support Team: CLONED FROM T480871: ASPxGridView - Responsive Layout - Columns with predefined width aren't collapsed when the grid has a vertical scrollbar]
Hi Lex,

Sorry for taking so long to answer, I've had an accident here.
Could you provide me a sample of how to remove the fixed width at runtime on server side, please?
Then I'll remove it on the initialization of the gridview, based on the users viewport (I have it in session).

T hanks,
Bruno.

Answers approved by DevExpress Support

created 8 years ago

Bruno,

I suggest you use the following code to accomplish your task:

C#
var grid = sender as ASPxGridView; var width = grid.Columns[0].Width; for(int i = 0; i < grid.Columns.Count; i++) { grid.Columns[i].Width = Unit.Empty; }

Please note that it is necessary to restore the width of the columns on every next page request once you changed it on a callback, because otherwise the default width will be restored. I've created a sample project to demonstrate this approach. Let me know if you have further questions.

    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.