Hi, I am currently experimenting with BandsLayout in ASP.NET and had to read that RowIndex is only available in WinForms. Is there a plan to implement this in Webgrids?
ASPxGridListEditor - RowIndex in BandsLayout or adding multi-level columns in an ASP.NET ListView
Answers approved by DevExpress Support
Hello Patrick,
I have created a ViewController, which I tested with our FeatureCenter.Web app. Consider these implementation steps:
- In the YourSolutionName.Module.Web project, edit Model.DesignedDiffs.XAFML file using the Model Editor. Create required bands and add first-level columns into them. Do not add second-level columns into the same band, because we will do this in code. See the Model.XAFML file for more details:
XML<Views>
<ListView Id="BandTestObject_ListView">
<Columns>
<ColumnInfo Id="ProductID" OwnerBand="Band1" />
<ColumnInfo Id="UnitPrice" OwnerBand="Band2" />
</Columns>
<BandsLayout Enable="True">
<Band Id="Band1" IsNewNode="True" />
<Band Id="Band2" IsNewNode="True" />
</BandsLayout>
</ListView>
</Views>
2. Add the ViewController1.cs file to same project. Notice that we are locating the first-level column and add another orphan column into it programmatically:
C#var column11 = editor.Grid.Columns["ProductName"];
if(column1.Columns["ProductName"] == null) {
column1.Columns.Add(column11);
}
NOTE: we are handling the ModelSaving event to cancel saving these changes back to the Application Model. Runtime customizations made by end-users via the column/band chooser will NOT be saved by default. That is because the default ListView model does not provide any data structures to save this bands information + the ASPxGridListEditor itself does not provide such logic by default. If this functionality is important for you, you will need to perform additional implementation and testing. My example just shows a possible way to add bands to ASPxGridListEditor and I did not test it under all the possible standard scenarios. Having said that, you may consider other alternative solutions for this task, e.g. using a custom user control: How to: Show a Custom Data-Bound Control in an XAF View (ASP.NET)
This would be such a nice feature to have in XAF Web apps too. Since it appears this is supported in ASPxGridView since 16.1, it would be so cool if we could define these band layouts using the Model Editor in the same way we do for XAF Win apps. Pretty please :)
Hello Patrick,
You are correct that the IModelBandedColumnWin.RowIndex option is available for WinForms only. That is because the underlying ASPxGridView component we use in Web ListView (ASP.NET Controls and MVC Extensions > ASP.NET WebForms Controls> Grid View > Concepts > Data Representation Basics > Columns > Bands ) does not allow arranging column headers across rows in ASP.NET applications like in its WinForms GridControl counterpart.
Would you please attach a screenshot of the grid layout you want to achieve in the end? It is possible that it can be accomplished without this option, probably by writing code. We want to help you and look forward to hearing from you.
I am also changing the ticket's product from XAF to ASPxGridView so that the team could be aware of your requirements and could suggest the best solution as far as ASPxGridView is concerned once you reply. As for the XAF integration, you will likely be able to use the Extend Functionality > Access Grid Control Properties approach or a custom ViewItem/ListEditor from the Concepts > UI Construction > Using a Custom Control that is not Integrated by Default article. Do not hesitate to contact us further if you experience any XAF integration difficulties.
Hello Patrick,
I have found out that this functionality was actually supported by the ASPxGridView component in v16.1. I apologize for all the inconvenience here. I will try to make a simple XAF example for you. Please bear with me.