Get row indexes of selected cells from filtered rows.

3 posts, 0 answers
  1. özer
    özer avatar
    33 posts
    Member since:
    Jun 2020

    Posted 31 Dec 2020 Link to this post

    Hi.
    I have a RadGridView that SelectionMode property is set to CellSelect.

    Dictionary<int, string> drms = new Dictionary<int, string>();
     
    private void ddlSetDurum_SelectedIndexChanged(object sender, Telerik.WinControls.UI.Data.PositionChangedEventArgs e)
            {
                if (ddlSetDurum.SelectedIndex != 0)
                {
                    drms.Clear();
     
                    foreach (var item in rgvTakip.SelectedCells)
                    {
                        int i = item.RowInfo.Index; // Works fine if no column filtering is done
                        if (!drms.ContainsKey(i))
                        {
                            drms.Add(i, rgvTakip.Rows[i].Cells["tkd"].Value.ToString());
                            rgvTakip.Rows[i].Cells["tkd"].Value = ddlSetDurum.SelectedText; 
                        }
                    }
                    isDurumSet = true;
                    ddlSetDurum.SelectedIndex = 0;
                }
            }

     

    After filtering by any column, when I try to get the row index of the selected cells, it gives me the index number in the rows created after the filtering process.

    When I want to change the value of a cell using the obtained row index, this time it works according to the original table, not the filtered table.

    So I have to get the original index number of that cell before filtering.

  2. özer
    özer avatar
    33 posts
    Member since:
    Jun 2020

    Posted 02 Jan in reply to özer Link to this post

    I found the solution. It was very simple, the childRows property gives the indexes I want.
  3. Nadya
    Admin
    Nadya avatar
    509 posts

    Posted 04 Jan Link to this post

    Hello, özer,

    I am glad that you managed to find a solution that works for you. If you want to access the rows after filtering using the ChildRows collection is the right approach. The ChildRows collection is modified every time a data operation (grouping, sorting, filtering) occurs. More information is available here: https://docs.telerik.com/devtools/winforms/controls/gridview/rows/rows-vs-childrows#rows-vs-childrows 

    Should you have any other questions do not hesitate to ask.

    Regards,
    Nadya
    Progress Telerik

    Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Back to Top