Custom Renderer for a Single Cell

I’m looking to, in a ListGrid, have a single cell be a dropdown (like .setValueMap() provides) without modifying the behavior of the other cells in the same column.

So far I’m having no luck, it seems like I can modify an entire column by editing ListGridFields but I can’t seem to get a single cell to have a custom editor.

Thanks in advance,
Alden

Try overriding ListGrid.canEditCell(row, col)

Also read this document.

Thanks for the quick response, but I’m afraid that despite your guidance and the reading you suggested I wasn’t quite able to figure it out. I can see how overriding ListGrid.canEditCell(row, col) would allow me to make specific cells editable or not, but not how I’d be able to change the nature of certain cells that way.

Just to clarify, I’m trying to make a single cell (say row 4, col 2) in a ListGrid editable through a dropdown (the behavior when a ValueMap is specified) while leaving all other cells editable as dictated by their ListGridField type (which by default is text).

Thanks,
Alden

It’s a nasty hack, but I managed to get it a semi working version of the behavior I was looking for by adding this:

	    fieldData.addRecordClickHandler(new RecordClickHandler() {
			public void onRecordClick(RecordClickEvent event) {
				if(event.getRecordNum() == 3) {
					fieldData.setValueMap("one", "two", "three");
				}
			}
	    });
	    
	    fieldData.addEditorExitHandler(new EditorExitHandler() {
			public void onEditorExit(EditorExitEvent event) {
				fieldData.setValueMap((Map)null);
			}
	    });

Obviously this will cause all kinds of nasty is the editor doesn’t exit after the field is clicked… but it’s a start. I’m be interested is someone has a less hackish solution.

Cheers,
Alden

Hi Alden,
I’ll add the following overridable methods ListGrid.getEditorType and ListGrid. getEditorValueMap which will allow you to, say, conditionally return TextItem or SelectItem.

Feel free to file an issue for this so that it can be tracked.

Sanjiv

Hi Sanjiv,

Did you add getEditorType and getEditorValueMap methods in smartGWT? I can find them only in smart client.

thank you