When I sort any column in the xamgrid the comboboxes lose its value
Is there any property that needs to be set for xamgrid?
Hi,
There isn't any particular property that'd you need to set.
Do you have a sample that shows this?
-SteveZ
Hello
I have attached a sample code
Attached images that show i get before and after sorting
In original code the combo and the autocomplete both get reset
Basically the ComboBox has an issue with the SelectedItem. When we virtualize a cell thats in view, b/c its no longer in view, we clear it's DataContext. B/c of this, the comboBox thinks its SelectedItem is null, and updates the binding...
To get around this you can create your own custom Column though, as we have to always clear the DataContext on TemplateColumns for performance reasons, and don't know what the actual content is going to be displayed is.
My colleague Devin created an article that explains this pretty well.
http://blogs.infragistics.com/blogs/devin_rader/archive/2010/07/08/creating-custom-columns-for-xamgrid.aspx
Also, in the upcoming 11.1 release, we will be adding a ComboBox column.
Thanks I'll add the Custom column for Combo, but it seems to be happening for the Autocompletebox that is also in the grid
Any suggestion for that
The one marked in red is the AutocompleteBox
Is there equivalent of AutocompleteBox in Infragistics controls?
You should be able to do this with a ValueConverter.
Where you'd set up a binding to the SelectedItem with a converter, that would convert Bar to and Id, and Convert back an Id to a bar.
I've created a custom column outlined in the above blog for the combo box. I have an issue with the binding though. My grid binds to Foo. Foo has a fk to bar (fkBarId) I set the item source of the combo box to be bar. The way this is set up is so that foo has an instance of bar in it, so when you bind to bar and set displaymember path to be Barname The real binding is Foo[x].Bar.BarName.
I just want the binding to be Foo[x].fkBarId as I don't want to have to bring back the Bar objects in each Foo. So my xaml looks like
<ComboBox:ComboBoxColumn Key="fkBarId" DisplayMemberPath="BarName" ItemsSource="{Binding Source={StaticResource viewModelSpy}, Path=DataSource.Bars}" Width="100" HeaderText="Bar Name"/>
I fixed this by just making the textBinding.path = column.key. This of course only shows the Id. Also when I try to bind on edit I have an issue. It can't convert the Bar Object back to an int when editing. Binding error is can not conert Bar object to fkBarId on Foo Object.
What is the best way to go about this? I'd rather not have to bring back/map the bar items in to Foo. The easy way is to create a ComboData object that is just Id/Name, place that on the model and bind accordingly. But if possible I would like to not have to place extra items on my data models.
The same SelectedItem issue happens with AutoCompleteBox, so you'd just create another column for it as well.