PDA

View Full Version : ToolTips to EditorTreeGrid cells



I_P
17 Jan 2012, 2:35 AM
Hello,

I want to add a tooltip(which will show cell's value) to every cell of EditorTreeGrid. How can I do it with GXT?

Thanks a lot!

Ersmarker
17 Jan 2012, 2:47 AM
You can use QuickTip.
You can see an examplein the BasicGrid example for the Change column:

http://www.sencha.com/examples/pages/grid/grid.html

I_P
17 Jan 2012, 4:48 AM
Thank for replying, but i need exactly EditorTreeGrid. I can't make quicktip work with EditorTreeGrid, because it needs column.setRenderer command and TreeGrid needs it either. I thought about overriding render method in TreeGridCellRenderer () like that : column.setRenderer(new TreeGridCellRenderer<TreeModel>()
{
@Override
// render method
});
But i can use only one TreeGridCellRenderer in TreeGrid and i need tooltip for every cell, so I'm still looking for solution...
And one more question if you don't mind...
My EditorTreeGrid has five columns.Two of them must not be editable and are just for information, so i need to disable editors in them. I tried cellEditor.getField().setEnabled(false) or cellEditor.setEnabled(false) and it works but looks awful. I just want my grid not to have reaction when user clicks on one of this columns. Is there any way to do it?

Ersmarker
17 Jan 2012, 5:23 AM
For the column using TreeGridCellRenderer you can override the getTemplate method of the TreeGridView and "insert" the tip.



final RegExp regExp = RegExp.compile("<span unselectable=\"on\" class=\"x-tree3-node-text\">");
tree.setView(new TreeGridView() {
public String getTemplate(ModelData m, String id, String text, AbstractImagePrototype icon, boolean checkable,Joint joint, int level) {
String s = super.getTemplate(m, id, text, icon, checkable, joint, level);
s = regExp.replace(s, "<span qtip='"+text+"' unselectable=\"on\" class=\"x-tree3-node-text\">");
return s;
}
});


For the rest of the columns you do as in the normal grid example.

I_P
17 Jan 2012, 6:59 AM
It works grate!Thanks a lot, Ersmarker! The first problem has been solved!
And nothing about the second one?

Ersmarker
17 Jan 2012, 7:15 AM
Maybe I don't understand your second issue, but...
don't set an editor in the columnmodel for the columns you don't want to edit.

sven
17 Jan 2012, 7:16 AM
.Two of them must not be editable and are just for information, so i need to disable editors in them.

Why do you set an editor for them in the first place than? If you do not set an editor, they are not editable.

I_P
18 Jan 2012, 2:43 AM
don't set an editor in the columnmodel for the columns you don't want to edit.


Why do you set an editor for them in the first place than? If you do not set an editor, they are not editable.

I tried it first and got NullPointerException. I thought i was because of cell editor, but after a little looking throught the code i found real problem and solved it. Now I just did't put celleditors into the columns and everything works exactly as I wanted. Thank you very much!