GridTextColumn customColumn = new GridTextColumn(); customColumn.UserCellType = typeof(GridImageCell); customColumn.MappingName = "ImageColumn"; public class GridImageCell : GridCell { private ImageView customerImage; private TextView textView; Bitmap bitmap;
public GridImageCell (Context context) : base (context) { customerImage = new ImageView (context); textView = new TextView(context) { Gravity = GravityFlags.Center }; this.CanRenderUnLoad = false; this.AddView (customerImage); this.AddView (textView); }
public MemoryStream LoadResource (String name) { MemoryStream aMem = new MemoryStream (); var assm = Assembly.GetExecutingAssembly (); var path = String.Format ("DataGrid.Resources.drawable.{0}", name); var aStream = assm.GetManifestResourceStream (path); aStream.CopyTo (aMem); return aMem; }
protected override void UnLoad () { if (this.Parent != null) (this.Parent as VirtualizingCellsControl).RemoveView (this); }
protected override void OnLayout (bool changed, int left, int top, int right, int bottom) { textView.Layout(0, 0, this.Width, 40); customerImage.Layout (0, 45, this.Width, this.Height - 40); }
public override void Draw (Canvas canvas) { base.Draw (canvas); textView.Text = "Image" + DataColumn.RowIndex; bitmap = (Bitmap)DataColumn.RowData.GetType ().GetProperty ("CustomerImage").GetValue (DataColumn.RowData); customerImage.SetImageBitmap (bitmap); }
protected override void Dispose (bool disposing) { if (bitmap != null) { this.customerImage.Dispose (); this.customerImage = null; this.textView = null; } base.Dispose (disposing); } |
Hi Guillaume,
To load a custom grid cell in SfDataGrid you need to create a column specifying the mapping name and the type of custom grid cell during creation itself. Hence this cannot be used for the dynamic columns as we do not know the property name that is bound with the column during the compile time.
Regards,
Prasanth
Hi Guillaume
We considered this 'LongPressEvent' as an feature request and a support incident has been created under your account to track the status of this requirement. Please log on to our support website to check for further updates.
https://www.syncfusion.com/account/login?ReturnUrl=/support/directtrac/incidents
Regards,
Dharmendar D.