/// <summary> /// Gets the property value that is reflected from the specified record. /// </summary> /// <param name="record"> /// The corresponding record to get the property value. /// </param> /// <param name="propName"> /// The corresponding property name to get the value. /// </param> /// <returns> /// Returns the property value for the specified record and property name. /// </returns> public override object GetValue(object record, string propName) { if (dataGrid != null) { if (cachedcolumn == null || !cachedcolumn.mappingName.Equals(propName)) { cachedcolumn = columns != null?columns.FirstOrDefault(col => col.mappingName == propName) : dataGrid.Columns.FirstOrDefault(col => col.mappingName == propName); } if (cachedcolumn != null) { if (cachedcolumn.IsUnbound) { return(dataGrid.GetUnBoundCellValue(cachedcolumn, record)); } if (cachedcolumn.ValueBinding != null && cachedcolumn.useBindingValue) { cachedcolumn.ColumnWrapper.DataContext = record; #if WPF if (cachedcolumn.ColumnWrapper.ValueBindingExpression.Status == BindingStatus.Unattached) { cachedcolumn.ColumnWrapper.SetValueBinding(cachedcolumn.ValueBinding); } #endif return(cachedcolumn.ColumnWrapper.Value); } } } return(base.GetValue(record, propName)); }
/// <summary> /// Gets UnBound Func Value for sorting and grouping /// </summary> /// <param name="view">View</param> /// <param name="dataGrid">DataGrid</param> /// <param name="column">Column</param> /// <returns>returns Func<string, object, object></returns> internal static Func <string, object, object> GetUnboundFunc(this CollectionViewAdv view, SfDataGrid dataGrid, GridUnBoundColumn column) { if (column.UnBoundFunc != null) { return(column.UnBoundFunc); } column.UnBoundFunc = (columnName, record) => { if (dataGrid != null) { return(dataGrid.GetUnBoundCellValue(column, record)); } else { return(null); } }; return(column.UnBoundFunc); }