Skip to content

Infragistics Community Forum / Web / Ignite UI for Blazor / IgbDataGrid Get Selected Row

IgbDataGrid Get Selected Row

New Discussion
Sean Doherty
Sean Doherty asked on Jun 8, 2022 9:58 PM

I'm trying to get the selected row from the IgbDataGrid.

1. First, the onselectionchange event does not appear to be firing?

2. Second once I can get this to fire, I want to get a row column value?

PS: Code blocks do NOT seem to work for HTML code.

<IgbDataGrid @ref="gridCourse"
DataSource=@data
Height="600px" Width="100%"
AutoGenerateColumns="false"
IsRowHoverEnabled="true"
RowHoverBackground="@HighlightColor" SelectionMode="GridSelectionMode.SingleRow"
EditMode=IgniteUI.Blazor.Controls.EditModeType.Row @onselectionchange="OnCourseEditSelectionChanged">
<IgbNumericColumn Field="course_id" HeaderText="Course Id" Width="120" />
<IgbTextColumn Field="course_name" HeaderText="Course Name" />
</IgbDataGrid>

public void OnCourseEditSelectionChanged(EventArgs e)
{
IgbGridSelectedItemsCollection q = gridCourse.SelectedItems;

string test = "1";
}

I'm just guessing as to how to get the selected row / column value since it never enters the code block.

Thanks

Sign In to post a reply

Replies

  • 0
    Andrew Goldenbaum
    Andrew Goldenbaum answered on Jun 8, 2022 9:58 PM

    Hello Sean,

    In order to handle the row selection change on the IgbDataGrid, I would recommend that you utilize the SelectedItemsChanged event of the grid. Below is a sample event handler that you can hook this event into:

    public void OnSelectedItemsChanged(IgbGridSelectedItemsChangedEventArgs e)
    {
       //your code here
    }

    Please note that you will need to have the SelectionMode of the IgbDataGrid set to one of the “row selection” enumerations (SingleRow or MultipleRows) in order for this event to fire. In cell selection, the SelectedCellsChanged event fires instead.

    Regarding getting the values that were selected, the event arguments’ AddedItems collection has information about the row that you selected.

    Please let me know if you have any other questions or concerns on this matter.

  • 0
    Haibara EIlish
    Haibara EIlish answered on Oct 22, 2022 4:05 AM

    I also did the same steps and then got the same error, does anyone have a solution for this? fnf

  • You must be logged in to reply to this topic.
Discussion created by
Favorites
Replies
Created On
Last Post
Discussion created by
Sean Doherty
Favorites
0
Replies
1
Created On
Jun 08, 2022
Last Post
3 years, 5 months ago

Suggested Discussions

Tags

Created by

Created on

Jun 8, 2022 9:58 PM

Last activity on

Jun 8, 2022 9:58 PM