I have an architecture that returns lists of objects via an IList interface (or IList<type> when using generics). I can easily bind this to an ultrawingrid but i don't seem to have any control over the ordering that the columns are displayed.
I'm calling SetDataBinding( <IList data>, null, true) have manualy defined a schema with only the columns i want to show but it's not taking the ordering that i assigned when i created in the designer dialog.
Is there a way i can specifically order the columns that are displayed when using an IList<> as the datasource?
Hi,
Is it honoring the hidden columns, but not the order? If that's the case, then something is wrong.
If it's not honoring either the hidden columns or the column order, then my guess is that the name of the band you defined in the schema is not the same as the name of the band in the actual data. You might want to just run the app and display the grid.DisplayLayout.Bands[0].Key to see what the root band key is, then make sure you use the same key at design-time when you define the schema.
Another option would be to handle the InitializeLayout event. In this event, you can set teh position of each column using the e.Layout.Bands[0].Columns[column key].Header.VisiblePosition of each column.
Thanks for the reply, i was able to figure it out.
Here is the deal for anyone having this issue.
From what i can tell, the designer is not working as expected. If you create a bunch of fields, then reorder them, the ordering is not properly coded in the designer.cs file. Creating columns generates a number of UltraGridColumn instances. A few lines down it calls teh VisiblePosition but it had the wrong value.
I found two fixes for this
1. Do as you say and manually assign VisiblePosition in InitializeLayout
or
2. Decide what columns you want and in what order, delete all columns in the designer, then recreate in the correct order. Doing it in the correct order in the first place seems to work fine. Their issue seems to be with reordering existing columns.
In my case i did both. I have a bunch of hidden columns but one that is visible should always be the last one. I just set it's VisiblePosition in InitialzeLayout to be sure that when the Chooser is used to unhide columns, they will not appear at the end