Hi all,
In the Outsystems Data grid, the column width is set by number in pixel (px), which makes the UI look very different in different screen zoom-in condition (such as 100% vs 150%).
I'd like to ask is it possible to set the column width in data grid as relative value such as "vw" or "%"?
Thanks
Hi @Cuong Tran
Outsystems doesn't provide relative column width setting, we can achieve that by handling the resize event of the page.
You put this JS in the Initialize:
The result:
Hi @Kiet Phan
Thanks for your reply.
I have tried to use your method by simply adding the JS script in the Grid On Initialize.
But when I tried to zoom-in and out the browser (100% to 150%), the grid is not adapting to the changes.
Maybe I'm missing something here?
The column actually change the size when you zoom in/zoom out. Let me give you the demostration.
In the code below I add console.log the width of column[0].
As you can see, the width of column was changed when I zoom-in/zoom-out.
This is exactly what I want, unfortunately I still cannot achieve it in my code. Perhaps some setting in the my grid is over-written this JS script.
Could you please sharing this oml file with me so that I can learn from it?
Thanks.
sure, here it is
pls check the attachment.
Hi @Cuong Tran,
Indeed OutSystems.GridAPI.GridManager.GetGridById($parameters.GridId).getColumns() only returns values if you are using columns.
Since you are using AutoGenerated grid please use:
OutSystems. GridAPI.GridManager.GetGridById($parameters.GridWidgetId)
.provider.columns
.forEach(function(col){
col.width = '*';
}
);
Please let us know if this helps.
Hi @rammurthynaidu boddu
Could you please be more specific how should I use the provided JS script, such as on which event this JS script being called?
If you remove the height that will happen ofc. If you're customizing the default behaviour you need to customize them all. Including the empty message. The elements are nested in a hierarchy so if you override one you need to override them all - this is simple Frontend logic, with nothing to do with Data Grid logic.One of the approaches is to define a minimum height to fit the message but you can do whatever you want:
.wj-control.wj-content.wj-flexgrid {
height: auto !important;
max-height: 400px;
min-height: 150px;
.datagrid-autogenerate {
https://www.outsystems.com/forums/discussion/71782/outsystems-data-grid-change-default-column-width/
@Cuong Tran
hello, was it OK, do you need any help.
hi @Kiet Phan,
Sorry I was out-of-office for a week so I could not get back to you in time.
Also thank you for checking on me. I have checked and you oml. file works like a charm.
You're welcome. Enjoy your weekend :)