2014-10-29 42 views
1

我需要在網格單元格中添加工具提示,但是此工具提示必須允許用戶在工具提示內選擇文本。我正在使用QuickTip。如何在網格單元上使用QuickTip Sencha GXT 3.1.1?

ColumnConfig<ClientModel, String> clmName = new ColumnConfig<ClientModel, String> 
(dpGridModel.name(), 150, "Name"); 
clmName.setCell(new TextCell() { 
     @Override 
     public void render(Context context, String value, SafeHtmlBuilder sb) { 
      if (value != null) { 
       StringBuilder bAux = new StringBuilder(); 
       ClientModel c = lstModel.get(context.getIndex()); 
       bAux.append("<div style='width:100%;height:21px;' qtip='<table>"); 
       bAux.append("<tr><td><b>ID:</b></td><td>" + c.getId() + "</td></tr>"); 
       bAux.append("<tr><td><b>Name:</b></td><td>" + c.getName() + "</td></tr>"); 
       bAux.append("<tr><td><b>Adress:</b></td><td>" + c.getAddress()+ "</td></tr>"); 
       bAux.append("<tr><td><b>City:</b></td><td>" + c.getCity()+ "</td></tr>"); 
       bAux.append("<tr><td><b>Email:</b></td><td>" + c.getEmail() + "</td></tr>"); 
       bAux.append("<tr><td><b>Phone:</b></td><td>" + c.getPhone() + "</td></tr>"); 
       bAux.append("<tr><td><b>Zip Code:</b></td><td>" + c.getZipcode() + "</td></tr>"); 
       bAux.append("</table>'>" + value + "</div>"); 
       sb.appendHtmlConstant(bAux.toString()); 
      } 
     } 

    }); 

QuickTip t = new QuickTip(gridClient); 
t.setAllowTextSelection(true); 
t.setClosable(true); 

鼠標移動時,工具提示會隱藏。我需要什麼Tooltip等待通過關閉點擊隱藏,如ToolTip與ToolTipConfig。

我嘗試過使用QuickTip和ToolTipConfig這樣。

QuickTip cqt = new QuickTip(gridClient); 
cqt.setMaxWidth(650); 
cqt.setClosable(true); 
cqt.setQuickShowInterval(500); 
cqt.setAllowTextSelection(true); 
ToolTipConfig config = new ToolTipConfig(); 
config.setAutoHide(false); 
cqt.setToolTipConfig(config); 

它的工作原理QuickTip不躲,但出現空白工具提示QuickTip

感謝您的幫助以上:d

回答

2

,因爲當你在QuickTip調用setToolTipConfig第二次嘗試不起作用對象它將爲QuickTip創建一個新的工具提示,這不是我們想要的。

在我們只需要自動隱藏設置爲false,但沒有方法在QuickTip類要做到這一點,這樣的選擇是使用這樣的更新方法第一種情況:

QuickTip t = new QuickTip(gridClient); 
t.setAllowTextSelection(true); 
ToolTipConfig config = new ToolTipConfig(); 
config.setAutoHide(false); 
config.setCloseable(true); // need to set it here otherwise it will be overwritten 
t.update(config); 
+0

幹得好,它就像一個魅力!但是有一個錯字。它應該是「config.setCloseable()」,而不是「config.setClosable()」 – Alex 2015-11-19 20:23:51

+0

Typo固定。謝謝! – 2015-11-23 13:12:32

相關問題