on 01-12-2014 1:36 PM
Hello,
some users make a double click on a table row, so the row will be selected on first click and deselected on the second. Is there a way to disable the second click or make a double click work to select a row?
Regards,
Igor
I found a solution that worked for me:
in the view:
oTable.attachBrowserEvent("dblclick", oController.onDblClick);
oTable.attachBrowserEvent("click", oController.onClick);
In the controller:
onInit : function() {
window.clicks = 0;
window.selectedIndex = -1;
},
onDblClick : function() {
oTable = sap.ui.getCore().byId('myTable');
oTable.setSelectedIndex(window.selectedIndex);
},
onClick : function() {
window.clicks = window.clicks + 1;
if(window.clicks == 1) {
setTimeout(sap.ui.controller("path.to.controller").clearClicks, 500);
} else if(window.clicks == 2) {
oTable = sap.ui.getCore().byId('myTable');
window.selectedIndex = oTable.getSelectedIndex();
}
},
clearClicks : function () {
window.clicks = 0;
window.selectedIndex = -1;
}
any suggestions?
Regards,
Igor
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Igor,
it seems the table component doesn't offer a property to influence this behaviour, so the only way to achieve this is to use a handmade solution as you did.
I've played around a littlebit and came up with a similar solution:
var lastSelIndex = -1;
oTable.attachEvent("rowSelectionChange", function() {
if (arguments[0].getSource().getSelectedIndex() > -1) {
lastSelIndex = arguments[0].getSource().getSelectedIndex();
}
});
oTable.attachBrowserEvent("dblclick", function() {
if (oTable.isIndexSelected(lastSelIndex)) {
oTable.removeSelectionInterval(lastSelIndex,lastSelIndex);
}
else {
oTable.addSelectionInterval(lastSelIndex,lastSelIndex);
}
lastSelIndex = -1;
});
One problem with your solution is, it doesn't work when you can select multiple rows.(In your click function you refer to window.selectedIndex = oTable.getSelectedIndex(); which will return the first selected row index, which is wrong when multiple rows are selected...)
Second, the function doesn't behave as expected when the users make some action between the 500ms delay in the setTimeout function.
Hope this is helpful,
greets ben
User | Count |
---|---|
81 | |
9 | |
9 | |
7 | |
7 | |
6 | |
6 | |
6 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.