Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    how can I prevent \n being replaced by <br> inside listgrid

    I have a list grid to display logs, with escapeHTML set to true so the log rows will stay on a single line even if there are html tags like div or br in the text. This works fine, except for some of the older logs that have \n in the text. For these logs, the \n is replaced by a br. This would seem to be a wonderful idea except for the fact that it forces those lines to span multiple rows, which leads to a SmartGWT bug where unexpected line heights throws off the row highlighting(the wrong row is highlighted). Is there a way to prevent SmartGWT from inserting br in the place of new lines? The list grid is pretty vanilla, but here it is in case it helps:

    Code:
    final DataSource dataSource = new DataSource(..."logs"){{
    	setFields(new DataSourceDateTimeField("createDate"),
    	new DataSourceTextField("username", "User"){{
    		setValueXPath("user/username");
    	}},	new DataSourceTextField("action"){{
    		setValueMap(EnumUtil.asMap(Enums.Log.Action.values()));
    	}},	new DataSourceTextField("log"));
    }};
    RefreshableListGrid logs = new RefreshableListGrid(){{
    	setDataSource(dataSource);
    	setFields(new ListGridField("createDate", 100){{
    		setFilterEditorType(new DateItem());
    	}}, new ListGridField("machine", 100), 
    		new ListGridField("username", 100), 
    		new ListGridField("action", 80), 
    		new ListGridField("log"){{
    			setEscapeHTML(true);
    		}}
    	);
    	setCanMultiSort(false);
    	setShowFilterEditor(true);
    	setFilterOnKeypress(true);
    	setAutoFetchData(true);
    	addRecordDoubleClickHandler(new RecordDoubleClickHandler() {
    		@Override
    		public void onRecordDoubleClick(RecordDoubleClickEvent event) {
    			new LogWindow(EvaluationTab.this.admit, dataSource, event.getRecord()).show();
    		}
    	});
    }};

    #2
    You basically need to turn off the built-in htmlEscape and write your own as a CellFormatter.

    Or clean up the data.

    Or set fixedRecordHeights:false to enable auto-sizing (the bad rollover is not a bug, it's just bad settings - see also enforceVClipping).

    Comment

    Working...
    X