81
Views
5
Comments
Solved
[OutSystems Data Grid] Data Grid Error after navigating to different page
outsystems-data-grid
Reactive icon
Forge asset by OutSystems
Application Type
Reactive

Hello 
I have used the same approach mentioned here a solution by @Ben where I want to triger a client action when the user select the checkbox from the grid, it works fine for me the good part, But when ever I try to navigate to another page it gives me the following error, let me know if we can fix this

I am attaching the Oml file that might helpWhat I am trying to do is,1) I wan to capture the ID's on a on change of a check box,  I will get the Id of the selected checkbox

2) I have added the JS and used it on a Oninitilize of grid handler



Thanks & Regards

Tousif khan 


POC_DataGrid.oml
2022-11-12 11-28-30
Gonçalo Martins
Staff
Solution

Hello @Tousif Khan 

I also did a small change to make it more performant using the following script:


OutSystems.GridAPI.GridManager.GetGridById($parameters.GridWidgetId).rowMetadata._grid._rows._g.onSelectionChanged = function(e) {
    var currentRowIndex = e.row;
    var currentRow = e._p._rows[currentRowIndex];
    
    //use col position to only trigger in the checkbox
    if(currentRow && e.col === -1){
        if(currentRow.isSelected) {
            $actions.SelectedIds(false,currentRow.dataItem.Employee_.Id);
        } else {
            $actions.SelectedIds(true,currentRow.dataItem.Employee_.Id);
        }
    }
    this.selectionChanged.raise(this, e);
}

Please check the oml attached on the screen DataGrid_Alternative.

Cheers,
GM

POC_DataGrid_Alternative.oml
2022-08-03 04-32-50
Ravi Punjwani

Hi Tausif,

The following minor changes to your script would fix this issue

GridAPI.GridManager.GetGridById($parameters.GridWidgetId).rowMetadata._grid._rows._g.onSelectionChanged = function(e) {
    var currentRowIndex =  e.row;
    var currentRow = e._p._rows[currentRowIndex];
    if(currentRow){
        if(currentRow.isSelected) {
            $actions.DeleteOnClick(true);
        } else {
            $actions.DeleteOnClick(false);
        }
    }
    this.selectionChanged.raise(this, e);
}


2023-10-21 19-42-11
Tousif Khan
Champion

Perfect, I just had to made a slight change, according to my Code It is Working Now,
I appreciate your help and quick response.

Thanks

2022-08-03 04-32-50
Ravi Punjwani

Happy to help out anytime Tausif, and glad it worked.

Cheers!

2022-11-12 11-28-30
Gonçalo Martins
Staff
Solution

Hello @Tousif Khan 

I also did a small change to make it more performant using the following script:


OutSystems.GridAPI.GridManager.GetGridById($parameters.GridWidgetId).rowMetadata._grid._rows._g.onSelectionChanged = function(e) {
    var currentRowIndex = e.row;
    var currentRow = e._p._rows[currentRowIndex];
    
    //use col position to only trigger in the checkbox
    if(currentRow && e.col === -1){
        if(currentRow.isSelected) {
            $actions.SelectedIds(false,currentRow.dataItem.Employee_.Id);
        } else {
            $actions.SelectedIds(true,currentRow.dataItem.Employee_.Id);
        }
    }
    this.selectionChanged.raise(this, e);
}

Please check the oml attached on the screen DataGrid_Alternative.

Cheers,
GM

POC_DataGrid_Alternative.oml
UserImage.jpg
Sarah Javed

@Tousif Khan As you worked on data grid previously can you plz help me when I added the check box column all the data in the grid is not visible now. 

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.