Created
June 10, 2022 03:07
-
-
Save srafay/106b91e4c9211fec222956ac344e12c7 to your computer and use it in GitHub Desktop.
Get SFGrid Ref from CellSelectedHandler Event (Syncfusion Blazor C#)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void CellSelectedHandler<T>(CellSelectEventArgs<T> args, SfGrid<T> grid) | |
{ | |
if (args.IsCtrlPressed) | |
{ | |
System.Reflection.FieldInfo grid = args.GetType().GetField("Parent", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static | BindingFlags.GetField | BindingFlags.Public); | |
var col = grid.FieldType.GetProperty("Columns"); | |
var wrapped = ObjectAccessor.Create(col); | |
var argsFM = ObjectAccessor.Create(args); | |
var gridFM = ObjectAccessor.Create(grid); | |
Type gridType = typeof(T); | |
var xx = grid.GetType().GetMember("Columns", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static | BindingFlags.GetField); | |
var x = grid.FieldType.GetMethod("get_Columns"); | |
dynamic dArgs = args; | |
dynamic dParent = dArgs.Parent; | |
var argsParent = args.GetType().GetMembers(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance).Single(x => x.Name == "Parent"); | |
var argsProps = args.GetType().GetProperties(BindingFlags.Public | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance).OrderBy(pi => pi.Name).ToList(); | |
var argsFields = args.GetType().GetFields(BindingFlags.Public | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance).OrderBy(pi => pi.Name).ToList(); | |
var tParent = typeof(T).GetMembers(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance); | |
var tProps = typeof(T).GetType().GetProperties(BindingFlags.Public | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance).OrderBy(pi => pi.Name).ToList(); | |
var tFields = typeof(T).GetType().GetFields(BindingFlags.Public | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance).OrderBy(pi => pi.Name).ToList(); | |
object ParentValue = Parent.GetValue(args, null); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To add event in SfGrid
<GridEvents CellSelected="args => CellSelectedHandler(args, ContractsPartiesGrid)" TValue="User"></GridEvents>