[OutSystems Data Grid Web] How to dinamically set column position?
data-grid
Web icon
Forge component by Platform Maintenance

Hi,

In my use case, i need to dynamically set the position of a column. We show the columns as months, and we need to set a column position to mark the end of the year. And since this position is not static we need to set it dynamically while or after rendering the grid.

Is there any way that we can achieve that already in the component? Or some other way that we can achieve this behaviour.

Thank you,

Rafael

Hi Gabriel,

Thank you for your help.

Yes, i had already saw that. But our problem was that we already had a lot of customization on the grid, so that alone did not work.

What we had to do was, set all columns property "allowDragging" as True,  then we called the "moveElement" function to move the element to the desired position, and in the end set the "allowDragging" property back to False.

Only, when the columns have the property "allowDragging" as True they can be moved to other position, using the move element function.

Best regards,

Rafael

Hey Rafael,


To achieve this you'll need a custom JS. I've attached a sample where you can see it working.

GridOS.ExternalAPI.afterGridInit(function(gObj) {
    setTimeout(function(){
        gObj.grid.columns.moveElement(0, 1);
        gObj.grid.columns.moveElement(4, 5);
    }, 100);
});


DataGrid_MoveColumns.oml

Hi Gabriel,

Thank you for your help.

Yes, i had already saw that. But our problem was that we already had a lot of customization on the grid, so that alone did not work.

What we had to do was, set all columns property "allowDragging" as True,  then we called the "moveElement" function to move the element to the desired position, and in the end set the "allowDragging" property back to False.

Only, when the columns have the property "allowDragging" as True they can be moved to other position, using the move element function.

Best regards,

Rafael

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