For the listGrid's fields, what do I do to make them have a fixed width and have a scroll bar that can scroll left and right when the width for each field is greater than the width of the grid altogether. Thanks.
Announcement
Collapse
No announcement yet.
X
-
To make a field fixed width, just set field.width. The grid as a whole will scroll if the total field width is larger than the grid width.
I'm not sure if you mean that you want each individual field to scroll independently. canFreezeFields:true partly offers this functionality, but if every single field needs to scroll independently, you'd need an HLayout of ListGrids or similar structure.
-
Thanks for the reply. Right now all the grid's headers come back as squeezed boxes. I want the ListGrid to show its, I guess I would call it, "autoFit" width. From there if the user wants to see the rest of the fields and its data that are not currently shown, they can scroll right or left. Thanks.
Comment
-
Originally posted by IsomorphicTo make a field fixed width, just set field.width. The grid as a whole will scroll if the total field width is larger than the grid width.
I'm not sure if you mean that you want each individual field to scroll independently. canFreezeFields:true partly offers this functionality, but if every single field needs to scroll independently, you'd need an HLayout of ListGrids or similar structure.
Does the fix field width issue fixed ?
I had similar problem ... setting the field width doesn't work.
My code is below:
Code:... grid.setShowFilterEditor(true); grid.setFilterOnKeypress(true); grid.setCanDragSelect(true); grid.setWidth("70%"); grid.setHeight100(); grid.setAutoFetchData(true); grid.setAlternateRecordStyles(true); grid.setDataSource(datasource); ListGridField f[] = grid.getFields(); for (int i=0; i<f.length; ++i) { f[i].setWidth(150); } ...
I tried a lot of "autofit" related API ... no one work ... all fields are
show and with "tiny" width which is hard to visible ...
Regards
KC
Comment
-
Try this: call grid.setFields() after setting the dataSource. The fields are lazily created so trying to reference them during initialization doesn't work. However, calling setFields() will cause the dataSource fields to be mapped into the grid and then you can set an individual column width as desired.
dave
Comment
-
Originally posted by davidj6Try this: call grid.setFields() after setting the dataSource. The fields are lazily created so trying to reference them during initialization doesn't work. However, calling setFields() will cause the dataSource fields to be mapped into the grid and then you can set an individual column width as desired.
dave
Your suggestion is consistent with what I found ... I did setFields() inside
Datasource before bind to ListGrid. It will be great if I can do this:
grid.setFields(datasource.getFields())
But there is not getFields() function for DataSource.
Re-create a set of ListGridField and call grid.setFields(list_grid_files)
solve the problem as I mentioned before ... but I don't like this
solution because I need to prepare the list of fields twice (one for
DataSource, the other for ListGridField).
KC
Comment
-
Originally posted by davidj6I don't use SmartGWT but in the core library you can call grid.setFields() with no arguments and it pulls everything from the dataSource automatically.
Cool, it works !!!
Just grid.setFields() will be enough. And all field width, attributes ...
could be completely determined inside DataSource (not in view).
Thanks, this is a great tip.
Regards,
KC
Comment
Comment