DynamicForm overflow width

Hello.

I have my dynamic form with an text item and a canvas item that contains a listgrid.
By default the listgrid takes all the available width space of the form. Perfect.
The problem is that if the textItem’s title is large the whole form overflows because the listgrid takes more space than it should.

Now I don’t want to set fixed width for the title column because I never know the title’s text length, text is dynamically inserted. How can I ensure that the listgrid doesen’t take more space than available in the form?

Here I added an very simple abstract example (just copy paste to run) that simulates my what is happening in my application:

	public void onModuleLoad() {

		final DynamicForm dynamicForm = new DynamicForm();
		dynamicForm.setBorder("3px solid blue");
		dynamicForm.setWidth100();
		dynamicForm.setMargin(1);
		
		final CanvasItem canvasItem = new CanvasItem();
		canvasItem.setTitle("very_very_long_title");
		HLayout layout = new HLayout();
		layout.setBackgroundColor("#ccc");
		canvasItem.setCanvas(layout);
		
		dynamicForm.setFields(canvasItem);
		
		new Timer() {
			public void run() {
				canvasItem.setTitle("short_title");
				dynamicForm.markForRedraw();
			}
		}.schedule(2000);
		
		dynamicForm.draw();
        
    }

P.S. I am using just an HLayout instead of a list, but the result is the same.

A ListGrid and a Label in an HLayout will work as a means of having a labeled grid fill the remaining space, with a variable text length. This isn’t something the form tries to do as it would be far less efficient if it did.

So, your approaches are:

  1. take this one part of the form and make it a separate Layout instead
  2. “measure” all the labels by rendering them offscreen in a Canvas and calling getVisibleWidth(), and set that as the size of the first column when you create the form.