Best approach to selecting a row programmatically on a grid(angular2)

Posted by: jmcookle on 4 October 2017, 10:44 pm EST

    • Post Options:
    • Link

    Posted 4 October 2017, 10:44 pm EST

    We are using WjFlexGrid in a project. So, far it works well. We have functionality where we store the state of the grid to do a parent/child relationship concept. Users selects a row, clicks on a button to bring up child information about that parent in another grid. When a user returns to the parent, we would like to select that row for them so they can continue to do something else with that selected row.

    I have tried doing a forEach to navigate in the rows shown to select which one, but I cannot get a handle on that row.

    this.grid.rows.forEach(row => {

    console.log(row);

    }

    });

    I have also tried something as simple as :

    for (var j = 0; j< this.grid.rows.length - 1; j++) {

    but the length is 0 and can’t get at the rows that way either.

    When I do a console.log(this.grid.rows) I see all 10 rows there, but I cannot seem to work with the rowCollection as easy as I thought. Is this possible? Any suggestions would be appreciated.

    Thank you,

    Jeff

  • Posted 5 October 2017, 1:02 am EST

    I may have found a way by using the (loadedRows)=“loadedRows(grid,$event)” on the grid and then selecting the rows using that approach. I will work with that.

  • Posted 8 October 2017, 5:59 pm EST

    Hi Jeff,

    We are sorry for the late reply.

    You may use select method to select the row in FlexGrid. Please refer to the following code snippet for the same:

    
    Suppose we would like to select 2 row in FlexGrid
    grid.select(2,0,2,0);
    
    

    ~Manish Kr Gupta

  • Posted 24 October 2017, 11:03 am EST

    To satisfy the TypeScript compiler, specify the CellRange argument explicitly:

    this.flex.select(new CellRange(1, 0, 1, this.flex.columns.length - 1), true);
    
  • Posted 24 October 2017, 6:16 pm EST

    Hi Calvin,

    Thanks for mentioning this point. You can also use selection property and assign range to this property.

    ~Manish

  • Posted 26 July 2023, 3:44 pm EST

    how can we add unit test case for grid.select(2,0,2,0); in jasmine. Please help. I am using it in my code

  • Posted 27 July 2023, 9:33 pm EST

    Hi,

    It seems you have also created a new thread for this query, which has been answered here - https://www.grapecity.com/forums/wijmo/unit-test-cases-for-wjcgrid-flexgrid-and-wjcgridfilter-flexgridfilter-and

    Here’s a copy of the response -

    There is no official documentation yet available for writing unit tests on Wijmo controls, however, you can refer to the attached sample in which some basic testing is performed on FlexGrid and FlexGridFilter. Similarly, you can write more unit tests as per your requirements.

    We have added the unit test for testing the ‘select’ method to the sample below.

    In case, you face any issues, please let us know.

    Regards

    UnitTestGrid_app.zip

Need extra support?

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

Learn More

Forum Channels