I have searched but only came up with answers for the WPF xam grid.
No matter where I look I can't seem to figure out how to programmatically set the column order of a xam web grid. Further I don't see how I can determine the current order of the columns so I can even save them.
Hoping you guys can provide a pointer to the info to make this happen, I'm trying to save and restore a user's settings for the column order that they've performed by dragging the columns around.
Thanks.
-Chuck
Hi Chuck,
The Grid's Column's Collection is the order in which the columns are being displayed.
If the user moves a Column around, that collection is updated.
If you would like to move a column in the code behind, you would use that collection, and It's Add, Remove, Insert methods.
You may want to check out our Nov CTP as well. As we introduced a Control Persistence Framework, for saving off information, such as the Column order of the XamWebGrid.
http://es.infragistics.com/dotnet/netadvantage/silverlight/persistence-framework.aspx#Overview
-SteveZ
Stephen,
This is working, however, I've run across a problem that's caused by my adding columns at run time.
Previously I had all the columns in the grid and was showing/hiding them, but then there was no way to change their order. So now I'm using the Columns collection to control the order, but I need to remove and add them in the order I want since I must do them as a group.
The problem comes in when I am filtering the grid programatically using FilteringSettings.RowFiltersCollection.Add(filterCol). If the column isn't there (because the user may have hidden it) I need to add it so the filter will work. This works fine, except for template columns. When I add the fitler I get a large error, but it seems the problem lies in the fact that the column doesn't have a DataType. This never was a problem before when I was simply showing/hiding columns, so I know the filters are good.
Anyway, I figure this is happening because I'm loading the ItemTemplate with a DataTemplate at run time and the grid hasn't yet "figured out" what the column data type is yet.
I tried setting the DataType property directly but it's not accessible at run time (but is accessible during debugging via immediate window).
Any resolution you can share?
So, the DataType of a TemplateColumn is not calculated by what's in it's DataTemplate. It is instead calculated by the Key of the Column. Which is why it's important that your key map to the property on your data object. If it doesn't, then Sorting, Filtering, etc won't be supported for that column.
However, i did check out the code, and it does look like there is a bug there, where if you add a TemplateColumn at runtime, after the itemsource has already been initialized, that particular column type isn't loading it's DataType.
I have logged a bug for this, and will make sure you're associated with it, so that you're notified when the fix is released.
Thanks,