getCellValue function of GridFramework.js throws error during paging

Posted by: dtghuge on 7 September 2021, 11:12 pm EST

  • Posted 7 September 2021, 11:12 pm EST

    Hi Team,

    We are using Wijmo Grid in OutSystems Reactive.

    We have the functionality to get a particular cell value on check of row checkbox.

    On check, we are calling GridOS.ExternalAPI.getCellValue(rowNumber, CellNumber, GridID) by passing current row number, cell number and gridId

    This call gives us the correct value (cell’s value of checked row) when we are on 1 page and checked any checkbox (before paging) but when we do paging and select any row from second and onwards page, it throws an error saying

    _osjs.js?11_10_1_23852:5 TypeError: Cannot read properties of undefined (reading 'dataItem')
    at GridPanel.getCellData (WijmoGridJS.js?6405:14)
    at Object.getCellValue (GridFramework.js?6405:7916)


    below are the code block of GridFramework.js which throws an error at _grid.cells.getCellData(row, col, false); line

    // GridOS.ExternalAPI.getCellValue -> get the value of a cell
    getCellValue: function (row, col, gridId) {
    var _grid = GridOS.ComponentUtils.getGridObjectById(gridId).grid;
    var value = _grid.cells.getCellData(row, col, false);
    return value;
    },


    How to deal with this condition as GridFramework.js managed by GrapeCity

    Thanks
    Dhanraj
  • Replied 8 September 2021, 11:53 pm EST

    Hello,

    As per our understanding, you are trying to get the cell value regardless of the paging, in case you are using client-side paging then you can simply get the cell value using the getCellData method of FlexGrid as you already know but the issue might be occurring because you are trying to access the row dataItem from the previous page. As the rows collection only contains the current page rows instances.

    Note grid.getCellData(row, col) will only provide you the current page cellValue, also make sure that the row and col parameter values are in the range of the current page.

    If possible could you please provide some more information about the paging or a sample replicating the issue? so that we can investigate more to assist you better.

    Regards
  • Replied 13 September 2021, 4:49 pm EST

    Hello Sonu,

    Thank you for the quick response!

    As you said, "Note grid.getCellData(row, col) will only provide you the current page cellValue, also make sure that the row and col parameter values are in the range of the current page", you are correct!

    When we do paging, we have to pass row numbers in the range of the current page.

    Could you please help me to get row number in the range of the current page?

    Thank you!
  • Replied 14 September 2021, 10:14 pm EST

    Hello,

    If you wish to get the row indexes in the range of the current page you may simply use the following logic:

    currentRowIndex = rowNumber % grid.collectionView.pageSize // rowNumber is your row number


    Note: when using paging the rows collection only contains the number of rows as the page size, so if you are already getting the rows from the current page then it would not be necessary to use the above logic, however, if you are passing row index from another source(exceeds the page size range) you can use the above logic.

    Hope this will resolve your issue, if not then let me know.

    Regards
Need extra support?

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

Learn More

Forum Channels