The DataGrid have an option to show Checkbox as row header, is it possible to call a client action upon ticking the checkbox? I wanted to get the current row data upon doing so.
Hi Kenneth,
I do have a workaround to suggest based on the observation: On checkbox selection, the entire row gets selected. I would suggest following the mentioned approach only if you can't wait for the update from OutSystems about this requirement.
JavaScript Snippet:
GridAPI.GridManager.GetGridById($parameters.GridWidgetId).rowMetadata._grid._rows._g.onSelectionChanged = function(e) { var currentRowIndex = e.row; var currentRow = e._p._rows[currentRowIndex]; if(currentRow.isSelected) { var objectName = Object.keys(currentRow._data)[0]; var rowData = currentRow._data[objectName]; $actions.SetCheckedRowData(rowData, JSON.stringify(rowData)); } this.selectionChanged.raise(this, e); };
Note: The screen action will only get invoked when the checkbox is selected.
Demo Screen: GetRowDataOnChkBoxSelection
Refer to the attached oml
I hope this helps you!
Kind regards,
Benjith Sam
Hi Benjith,I have a similar requirement that an entire row is selected, on Row Number selection in Data Grid and the data of the selected row is then used to fetch the metadata of the selected row through an API in another screen. The user can select only row row at a time.
So, I'm using your implementation and changed this in my grid:
But, the row is not selected on clicking the row number in the grid.Thanks in advance.
Hi Aman,
Refer to my reply in your main post: how-to-select-a-single-row-in-data-grid
@Benjith Sam I used below javascript in Grid OnInitialize event and it was working fine till date but recently when i upgraded Outsystem Datagrid component to version 2.15.0 the functionality stopped working.
I tried to debug it and found whenever i check/uncheck checkbox on datagrid the client action does not gets called (earlier debugger use to hit on the start point of the client action).
please suggest what can be done here.
Hi @Kenneth1!Unfortunately, it isn't possible to call a client action when the checkbox is checked, and we don't have a workaround for that, but I added to our backlog the creation of a new event that will allow you to do that. We don't have a timeline for this feature yet but I will let you know as soon as we have one.Best regards,Jéssica
Hello @Benjith SamI have used the same approach 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 thisThanks & RegardsTousif khan
Hello @Tousif Khan
Can you please share a sample oml and the steps to reproduce it?
Cheers,GM
Hello @Gonçalo Martins 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
@Tousif Khan's question was followed up here
@Benjith Sam Thanks for the posting. The JavaScript above seems to work when a Selection box is checked. It doesn't seem to fire when the box is unchecked. Same thing
Any ideas how to make it work for both checking and unchecking?
Actually, never mind, I just needed to read the code, it all works perfectly.