EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: zolotoy on July 12, 2015, 04:38:34 AM



Title: Autosize datagrid columns
Post by: zolotoy on July 12, 2015, 04:38:34 AM
Is there a way to have datagrid autosizing its columns in such a way they will take all available space? So, if a datagrid has just one column it will have its width equal to grid's width.

Thanks


Title: Re: Autosize datagrid columns
Post by: jarry on July 12, 2015, 07:06:22 PM
Just set the 'fitColumns' property to true, or use the datalist component instead.


Title: Re: Autosize datagrid columns
Post by: zolotoy on July 13, 2015, 03:07:49 AM
fitColumns allocates enought space to snow data, but it does not take all grid's width See attached.


Title: Re: Autosize datagrid columns
Post by: jarry on July 13, 2015, 07:22:27 AM
You must set width for each columns. If your issue continues, please show some code snippets to demonstrate your issue.


Title: Re: Autosize datagrid columns
Post by: zolotoy on July 13, 2015, 07:38:45 AM
Well, yes, I can set column widths to some concrete values. But that's not a good way of designing things. Concrete values can cause problems on different screen resolutions.
I am attaching another screenshot where it works automatically.


Title: Re: Autosize datagrid columns
Post by: jarry on July 13, 2015, 09:31:57 AM
You can assign percentage width to a column in DataGrid. If you have only one column, set 100% width for it.

http://www.jeasyui.com/demo/main/index.php?plugin=DataGrid&theme=default&dir=ltr&pitem=Fluid%20DataGrid

Please search the answers from the forum or tutorials or demos before posting your question.