I need access to the Row Data from within the Body Template; at the moment I can only get the Value of the passed in data. Will this be coming soon as I need to make a discission on what suite of controls to use for an upcoming project. Until this is possible the current grid is no use.
Hello David,
You can access the grid’s row object from the IgbCellTemplateContext in your BodyTemplate handler using the following code, where "GetBodyTemplate" would be hooked into the corresponding column's BodyTemplate property:
public RenderFragment GetBodyTemplate(IgbCellTemplateContext ctx) { IgbGridCellIdentifier id = ctx.Cell.Id;
IgbRowType row = this.GridRef.GetRowByIndex(id.RowIndex);
var dataItem = row.Data;
return@<div>your_template_here</div>; }
I hope this helps you. Please let me know if you have any other questions or concerns on this matter.
I tried the above sample and I get a System.InvalidOperationException cannot synchronously invoke a method without IJSInProcessRuntime
This error is thrown on the line below.
IgbRowType row = this.GridChecks.GetRowByIndex(id.RowIndex);
I have tried the code I recommended in a sample project of my own, but I cannot seem to reproduce the behavior you are seeing. Would it be possible for you to please answer the following regarding this behavior?
1. What version of the IgniteUI.Blazor packages are you using? I am targeting 22.2.65 (latest at the time of writing this).
2. Are you using a Blazor Web Assembly or Server application? If you are using server, you may want to await the GetRowByIndexAsync method instead.
Please let me know if you have any other questions or concerns on this matter.
I am using the latest version I am also using Blazor Server. I have managed to get around the issue for now by looking up the primary key from my collection and using that within the template.
Thank you for your update on this matter. I am glad you were able to utilize the primary key within the template to get the data item.