Search code examples
smartgwt

Prevent a column to be dragged or resized


I have a column in a ListGrid and I want this column to be frozen. I don't want users to be able to drag the header and resize this column's width.

I tried

column.setCanDragResize(false) 

but had no luck.

Any suggestions?


Solution

  • First plz post code snippet or at least smart GWT version. Second, that method works fine in this case:

        ListGrid list = new ListGrid();
        list.setWidth(500);
        list.setHeight(300);
    
        ListGridField listField = new ListGridField("first");
        listField.setCanDragResize(false);
    
        list.setFields(listField);
        list.draw();
    

    If u want all fields to be disabled then you can use:

        ListGrid list = new ListGrid();
        list.setCanResizeFields(false);
        list.setWidth(500);
        list.setHeight(300);
    
        ListGridField listField = new ListGridField("first");
    
        ListGridField listField2 = new ListGridField("second");
    
        ListGridField listField3 = new ListGridField("third");
    
    
        list.setFields(listField,listField2,listField3);
        list.draw();
    

    EDIT: you can also set list.setCanReorderFields(false); if u dont want to reorder fields

    Regards, Jakov A.