SearchFlags don't have any flag to ignoreHidden

Posted by: davide.vago on 19 August 2021, 7:21 am EST

    • Post Options:
    • Link

    Posted 19 August 2021, 7:21 am EST

    Hi there,

    I’m reaching out as I noticed a weird behaviour of SJS SearchCondition which differs from the MS Excel experience.

    Let’s say you have a Worksheet that contains hidden columns and you search within the Sheet for values contained in the hidden columns.

    The default behaviour you get from SJS is a result giving you the indexes of the column and row which are actually hidden, the MS Excel experience instead ignores the hidden columns and returns either a visible result or no results (if the value you are searching for is just available within hidden columns)

    I would suggest to implement an additional flag to SearchFlags so the developer (your client) can decides to either point to an hidden column or ignore results in hidden columns/rows

  • Posted 20 August 2021, 6:12 am EST

    Hi Davide,

    Thanks for the information. We have made an enhancement request on your behalf. We will update you on the development of this feature. The internal ID for this issue will SJS-9776.

    Regards

    Avinash

  • Posted 25 August 2021, 7:59 am EST

    Hi Davide,

    They informed us that for this, you could simply judge the search result row index or col index as a visible row/column.

    Regards

    Avinash

  • Posted 31 August 2021, 4:05 am EST

    Hi Avinash,

    Would you please provide an example to look at?

    Thanks,

    Davide

  • Posted 1 September 2021, 12:32 am EST

    Hi Davide,

    For this whenever you get the result from searching, before changing the selection you just need to check the cell is visible or not. Please refer to the following code snippet and attached sample that demonstrates the same.

    
      if (searchResult != null && searchResult.searchFoundFlag != spreadNS.Search.SearchFoundFlags.none) {
                        spread.setActiveSheetIndex(searchResult.foundSheetIndex);
                        var sheet = spread.getActiveSheet();
                        if (isVisibleCell(sheet, searchResult.foundRowIndex, searchResult.foundColumnIndex)) {
                            sheet.setActiveCell(searchResult.foundRowIndex, searchResult.foundColumnIndex);
                            if ((searchCondition.searchFlags & spreadNS.Search.SearchFlags.blockRange) == 0) {
                                sheet.setActiveCell(searchResult.foundRowIndex, searchResult.foundColumnIndex, 1, 1);
                            }
                            /*scrolling*/
                            if (searchResult.foundRowIndex < sheet.getViewportTopRow(1) ||
                                searchResult.foundRowIndex > sheet.getViewportBottomRow(1) ||
                                searchResult.foundColumnIndex < sheet.getViewportLeftColumn(1) ||
                                searchResult.foundColumnIndex > sheet.getViewportRightColumn(1)
                            ) {
                                if (isVisibleCell(sheet, searchResult.foundRowIndex, searchResult.foundColumnIndex)) {
                                    sheet.showCell(searchResult.foundRowIndex,
                                        searchResult.foundColumnIndex,
                                        spreadNS.VerticalPosition.center,
                                        spreadNS.HorizontalPosition.center);
                                }
    
                            } else {
                                sheet.repaint();
                            }
                        }else{
                            /*hidden cell*/
                        alert('Not Found or may be hidden');
                        }
    
                    } else {
                        /*Not Found */
                        alert('Not Found');
                    }
    
          function isVisibleCell(sheet, row, col) {
                return sheet.getRowVisible(row) && sheet.getColumnVisible(col)
            }
    
    

    Regards,

    Avinash

    basicSearch.zip

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels