|
<Syncfusion.Blazor.Buttons.SfButton OnClick="OnClick">Select Row of index 15</Syncfusion.Blazor.Buttons.SfButton>
<SfGrid @ref="Grid" DataSource="@Orders" EnableHover=false AllowSelection=true Height="280" Toolbar="@(new List<string>() { "Add"})">
<GridEvents TValue="Order" DataBound="DataBoundHandler" ></GridEvents>
<GridColumns>
<GridColumn Field=@nameof(Order.OrderDate) HeaderText="OrderDate" Format="d" Width="110" Type="ColumnType.Date"></GridColumn>
</GridColumns>
</SfGrid>
@code {
SfGrid<Order> Grid;
public bool IsInitial { get; set; } = true;
. . .
public async Task DataBoundHandler(object args)
{
if (IsInitial)
{
await Grid.SelectRow(25);
JSRuntime.InvokeAsync<object>("scroll", 25); //here 25 is the row index to be selected
IsInitial = false;
} }
} |
Hi Walter,
How to implement this in reactjs ?
i got JSRuntime is not defined
Thanks in advance
Hello Geoff
I'm sorry but I'm using Blazor and not React so I think you need to add this request in the React's forum
Best Regards
Hi Geoff,
Greetings from Syncfusion support,
Based on your query want to scroll to selected row position. We have already discussed the same in our documentation. Please refer the below code snippet and documentation for more information.
|
[App.js]
const rowSelected = (args) => { if (grid) { const rowHeight = grid.getRows()[grid.getSelectedRowIndexes()[0]].scrollHeight; grid.getContent().children[0].scrollTop =rowHeight * grid.getSelectedRowIndexes()[0]; } };
|
Scroll to Selected row- https://ej2.syncfusion.com/react/documentation/grid/scrolling#scroll-to-selected-row
If you require further assistance, please do not hesitate to contact us. We are always here to help you.
Regards,
Vikram S