How to get rows that are visible

3 posts, 0 answers
  1. Allen
    Allen avatar
    2 posts
    Member since:
    Aug 2014

    Posted 03 Oct 2014 Link to this post

    I have a button that when the user clicks it will save the data from RadSpreadsheet into a DataTable.  I need to know how to loop through only the rows of the worksheet that are visible.  For example, the user starts with 200 rows and applies a data filter to get it down to only 20 rows.
  2. Allen
    Allen avatar
    2 posts
    Member since:
    Aug 2014

    Posted 07 Oct 2014 Link to this post

    I figured out a solution.  

            private Boolean IsRowVisible(int row, int colCount, Worksheet ws)
            {
                Boolean retValue = true;
                for (int col = 0; col < colCount; col++)
                {
                    IFilter filter = ws.Filter.GetFilter(col);
                    if (filter != null)
                    {
                        CellSelection objSelection = ws.Cells[row, col];
                        if (!filter.ShouldShowValue(objSelection.GetValue().Value))
                        {
                            retValue = false;
                        }
                    }
                }
                return retValue;
            }

  3. DevCraft banner
  4. Anna
    Admin
    Anna avatar
    99 posts

    Posted 08 Oct 2014 Link to this post

    Hi Allen,

    I would just like to confirm that your solution is what I would recommend as well. It follows correctly the logic the filtering feature uses to hide the necessary rows.

    On a side note, while the hidden rows and columns feature is still not available, there is an item logged for it in our feedback portal, where its progress can be tracked.

    Regards,
    Anna
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
Back to Top