I have a combo in grid
Main table that populates grid has the id and other table has the details/description of that ID
I have tried to follow the sample
http://labs.infragistics.com/silverlight/lobsamples/2010.3/#/Samples/ComboEditor/DataBinding/ComboInGrid
But that does not work with db
Any links
Hi,
I am not sure how you are providing the db to the xamGrid. If you use RIA Services you could check this blog post.
If this is not your case please provide more details.
HTH
What happens in case views are used
could you provide more details or a sample application illustrating the issues you are experiencing.
Regards,
ViewX
ViewY
ID
CityName
CityState
YID
1
xxx
TX
2
yyy
NY
3
zzz
MA
YDesc
Sunny
Warm
Cold
Grid should show
The one that I have highlighted in Yellow should be shown in textbox and when edit is clicked Combo should be populated with the data in ViewY with default selected
I am able to get the data in combo correctly with no default selected and not able to show textbox to show the ones in yellow in grid
there are two way you could achieve this scenario:
HTH,
Can you show how the Textblock would look like?
your TemplateColumn's ItemTemplate should look something like this:
<ig:TemplateColumn.ItemTemplate> <DataTemplate> <TextBlock Text="{Binding Path=YID, Converter={StaticResource yourConverter}, ConverterParameter={StaticResource ViewYData}}" /> </DataTemplate></ig:TemplateColumn.ItemTemplate>and the value converter should like something like: public class LookupValueConverter : IValueConverter{ public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { var viewY = parameter as Dictionary<int, string>; return viewY[(int)value]; } public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { throw new NotImplementedException(); //You don't need to ConvertBack since TextBlock is not an editor control }}HTH
Yes I have added the reference correctly
For somereason when i run the application I get error Provide value on 'System.Windows.Data.Binding' and this is on same line where i give the Converter
Hello,
check this link from msdn ElementName. Since the DataContext of the TemplateColumn cell is the bound row data, you need a way to access the DetailsTable1. To do so 'LayoutRoot' grid is used as binding source and the path is its data context and finally the DetailsView1.
Regarding the intellisence problem ... I am not sure what do you mean. (you need to add a using statement 'using SilverlightApplication2.Web;' )
What does the ElementName signify
Also I dont get intellisence for FirstOrDefault
I have checked the sample you provided. I was not able to debug it and to make sure everything works. However I got the general idea. Here are few pointers:
You need to provide the DetailsTable1(or DetailsView1 - don't know are they different) - basically you need to provide ConverterParameter the table that is mapping Id to TextDescription. Your TextBlock code should look something like this:
<TextBlock Text="{Binding Path=detailid1, Converter={StaticResource LookupValueConverter}, ConverterParameter={Binding ElementName=LayoutRoot, Path=DataContext.DetailsView1}}" />
After that in the Converter you look up the parameter(you should know and cast to the type it is). The Convert method should look :
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { var viewY = parameter as EntitySet<DetailsView1>; return viewY.FirstOrDefault(row => row.Id == (int)value).Description;}HTH,
Hello
Thanks for the solution
I have attached my sample code and db, what should be the ConverterParameter when its the database view
Any help is appreciated
I have attached the sample code