有沒有可能取消選擇一行而沒有按住控制鍵,只能通過點擊它?我的意思是,如果你點擊一個已經選擇的行,它應該取消選擇,而不必按住控制鍵。Rowunselect沒有按Ctrl +點擊
4
A
回答
2
我與Primefaces 3.4.2測試: XHTML頁面:
<script type="text/javascript">
function test(xhr, status, args){
if(args.unselecttest % 2 == 1){
stest.unselectAllRows();
}
}
</script>
<p:dataTable widgetVar="stest" selectionMode="single" selection="#{tabview.car}"
<p:ajax event="rowSelect" oncomplete="test(xhr, status, args);" />
豆:
private int count = 0;
public Car getCar() {
return car;
}
public void setCar(Car car) {
if (car.equals(this.car)) {
count++;
RequestContext reqCtx = RequestContext.getCurrentInstance();
reqCtx.addCallbackParam("unselecttest", count);
} else {
count = 0;
}
this.car = car;
}
-1
使用jquery切換功能。
$(selector).toggle();
+0
你能更具體的pleasa嗎?我正在使用primefaces datatable順便說一句。 – leostiw 2013-04-18 06:59:38
0
我得到了sollution。
我剛剛覆蓋了primefaces.js,實際上,我只是複製了Primefaces.Datatable的一部分,只是刪除了使用CtrlKey取消選擇該行所需的條件。
下面的例子:
原始的JavaScript的報價:
onRowClick: function (e, d, a) {
if ($(e.target) .is('td,span:not(.ui-c)')) {
var g = $(d),
c = g.hasClass('ui-state-highlight'),
f = e.metaKey || e.ctrlKey,
b = e.shiftKey;
if (c && f) {
this.unselectRow(g, a)
} else {
if (this.isSingleSelection() || (this.isMultipleSelection() && e && !f && !b && this.cfg.rowSelectMode === 'new')) {
this.unselectAllRows()
}
if (this.isMultipleSelection() && e && e.shiftKey) {
this.selectRowsInRange(g)
} else {
this.originRowIndex = g.index();
this.cursorIndex = null;
this.selectRow(g, a)
}
}
PrimeFaces.clearSelection()
}
},
你只要這部分改成這樣:
onRowClick: function (e, d, a) {
if ($(e.target) .is('td,span:not(.ui-c)')) {
var g = $(d),
c = g.hasClass('ui-state-highlight'),
// I changed it to true
f = true;
b = e.shiftKey;
if (c && f) {
this.unselectRow(g, a)
} else {
if (this.isSingleSelection() || (this.isMultipleSelection() && e && !f && !b && this.cfg.rowSelectMode === 'new')) {
this.unselectAllRows()
}
if (this.isMultipleSelection() && e && e.shiftKey) {
this.selectRowsInRange(g)
} else {
this.originRowIndex = g.index();
this.cursorIndex = null;
this.selectRow(g, a)
}
}
PrimeFaces.clearSelection()
}
},
,如果你需要幫助,你可以給我一個信息。
相關問題
- 1. mx:datagrid - ctrl +點擊
- 2. 按鈕沒有被點擊
- 3. webdriver沒有點擊按鈕
- 4. jquery沒有按鈕點擊
- 5. Extjs 3.4防止按Ctrl +鼠標點擊
- 6. 沒有敲擊聲按鈕點擊 - android
- 7. 射擊Ctrl + R鍵,Ctrl + A,按鈕上按Ctrl + Q的事件單擊
- 8. AutoHotkey的:有時按鈕沒有點擊
- 9. 將點擊視爲CTRL +點擊ListView
- 10. 多選框沒有按住Ctrl鍵單擊
- 11. 多選在點擊wihout CTRL沒有發送陣列後
- 12. Chromedriver按下「Ctrl +單擊」,而不是正常的「點擊」
- 13. 按鈕沒有響應點擊 - Android
- 14. JS沒有檢測按鈕點擊
- 15. 按鈕點擊沒有響應
- 16. 沒有按鈕發佈點擊
- 17. ListView ItemCommand沒有達到按鈕點擊
- 18. Javascript按鈕點擊沒有效果
- 19. 點擊Android按鈕,但沒有發生?
- 20. 按鈕點擊沒有任何活動
- 21. Jquery event.preventDefault沒有按住shift鍵點擊
- 22. Android SearchBar沒有點擊按鈕
- 23. 點擊按鈕顏色沒有改變
- 24. Firewatir:按鈕不點擊,沒有錯誤
- 25. swing:有沒有辦法讓一個按鈕/複選框僅在按下SHIFT或CTRL時纔可點擊?
- 26. jquery觸發Ctrl +點擊
- 27. autohotkey ctrl + click =點擊右鍵
- 28. CTRL +點擊不起作用
- 29. 模擬ctrl點擊Richfaces3.3 rich:extendedDataTable
- 30. Kendo驗證沒有點擊按鈕點擊
如果我有多選數據表,我該怎麼辦? – leostiw 2013-04-18 08:07:15
不,多重是不可能的,你必須使用控制鍵,你想象如何得到多個,如果不使用控制鍵:) – 2013-04-18 08:12:47
@leostiw你可以真正避免使用RichFaces數據表組件啓用「多鍵盤免費」選項的數據表組件。 [RichFaces DataTable - 多鍵盤免費](http://showcase.richfaces.org/richfaces/component-sample.jsf?demo=extendedDataTable&sample=exTableSelection&skin=blueSky)問候, – 2013-04-18 08:36:53