public class ViewModel : NotificationObject{
...
public IncrementalList<DynamicModel> DynamicCollection;
...
}
public class DynamicModel : INotifyPropertyChanged{
public Dictionary<string, object> _values;
...
public Dictionary<string, object> Values{
get {
return _values;
}
set {
_values = value;
}
}
public DynamicModel(){
this._values = new Dictionary<string, object>();
}
MappingName = "Values[" + colProperty + "]"
Where colProperty is the key for the value in the dictionary.
This was all working fine in version 15.1, but when I update to 15.2, sorting no longer works. Now, when I attempt to sort, it throws an error:
System.ArgumentException: 'Values[FILENAME]' is not a member of type 'IosGold.DynamicModel'
at System.Linq.Expressions.Expression.PropertyOrField (System.Linq.Expressions.Expression expression, System.String propertyOrFieldName) [0x00097] in /Library/Frameworks/Xamarin.iOS.framework/Versions/10.8.0.175/src/mono/mcs/class/dlr/
Is there something that I need to change to make this compatible again, or is this just a bug in this version of the library?
//QueryableViewExt.cs
public class QueryableViewExt : GridQueryableCollectionViewWrapper
{
public QueryableViewExt(IEnumerable source, SfDataGrid grid) : base(source, grid)
{
}
public override Expression<Func<string, object, object>> GetExpressionFunc(string propertyName, DataOperation operation = DataOperation.Default, DataReflectionMode reflectionMode = DataReflectionMode.Default)
{
Expression<Func<string, object, object>> exp = base.GetExpressionFunc(propertyName, operation, reflectionMode);
if (exp == null)
{
Func<string, object, object> func;
func = (propertyname, record) =>
{
var provider = this.GetPropertyAccessProvider();
return provider.GetValue(record, propertyName);
};
exp = (propertyname, record) => func(propertyName, record);
}
return exp;
}
}
//MainActivity.cs
public GettingStartedViewController ()
{
grid = new SfDataGrid();
viewModel = new ViewModel();
grid.AllowSorting = true;
grid.AutoGenerateColumns = false;
grid.ColumnSizer = ColumnSizer.Star;
viewModel.PopulateData();
grid.ItemsSource = new QueryableViewExt(viewModel, grid);
grid.GridTapped += Grid_GridTapped;
grid.Columns.Add(new GridTextColumn()
{
HeaderText = "Order ID",
MappingName = "Values[orderID]",
LineBreakMode = UILineBreakMode.WordWrap,
TextAlignment = UITextAlignment.Left,
HeaderTextAlignment = UITextAlignment.Center,
});
grid.Columns.Add(new GridTextColumn()
{
HeaderText = "Customer ID",
MappingName = "Values[customerID]",
LineBreakMode = UILineBreakMode.WordWrap,
TextAlignment = UITextAlignment.Left,
HeaderTextAlignment = UITextAlignment.Center,
});
grid.Columns.Add(new GridTextColumn()
{
HeaderText = "First Name",
MappingName = "Values[firstName]",
LineBreakMode = UILineBreakMode.WordWrap,
TextAlignment = UITextAlignment.Left,
HeaderTextAlignment = UITextAlignment.Center,
});
grid.Columns.Add(new GridTextColumn()
{
HeaderText = "Last Name",
MappingName = "Values[lastName]",
LineBreakMode = UILineBreakMode.WordWrap,
TextAlignment = UITextAlignment.Left,
HeaderTextAlignment = UITextAlignment.Center,
});
grid.Columns.Add(new GridTextColumn()
{
HeaderText = "City",
MappingName = "Values[city]",
LineBreakMode = UILineBreakMode.WordWrap,
TextAlignment = UITextAlignment.Left,
HeaderTextAlignment = UITextAlignment.Center,
});
grid.Columns.Add(new GridTextColumn()
{
HeaderText = "GroupProperty",
MappingName = "GroupProperty",
Width = 0
});
viewModel.RefreshGroup("firstName");
this.View.Add(grid);
} |