Grid edit: handle clicking on a link

This commit is contained in:
Aris Feryanto 2011-07-25 14:38:57 +08:00
parent c0613bd7e9
commit 59cbf2a3f1
3 changed files with 29 additions and 3 deletions

View File

@ -25,7 +25,8 @@
isEditCellTextEditable: false, // true if current edit cell is editable in the text input box (not textarea)
currentEditCell: null, // reference to <td> that currently being edited
inEditMode: false, // true if grid is in edit mode
cellEditHint: '', // text hint when doing grid edit
cellEditHint: '', // hint shown when doing grid edit
gotoLinkText: 'Go to link', // "Go to link" text
// functions
dragStartRsz: function(e, obj) { // start column resize
@ -608,6 +609,15 @@
// empty all edit area, then rebuild it based on $td classes
$editArea.empty();
// add goto link, if this cell contains a link
if ($td.find('a').length > 0) {
var gotoLink = document.createElement('div');
gotoLink.className = 'goto_link';
$(gotoLink).append(g.gotoLinkText + ': ')
.append($td.find('a').clone());
$editArea.append(gotoLink);
}
if ($td.is(':not(.not_null)')) {
// append a null checkbox
$editArea.append('<div class="null_div">Null :<input type="checkbox"></div>');
@ -1227,6 +1237,10 @@
$(g.cEdit).find('input[type=text]').focus();
e.stopPropagation();
}
// prevent default action when clicking on "link" in a table
if ($(e.target).is('a')) {
e.preventDefault();
}
});
$(g.cEdit).find('input[type=text]').focus(function(e) {
g.showEditArea();

View File

@ -2473,7 +2473,7 @@ span.mysql-number {
.cEdit .edit_area {
background: #FFF;
border: 1px solid #CCC;
border: 1px solid #999;
min-width: 10em;
padding: 0.3em 0.5em;
}
@ -2499,3 +2499,9 @@ span.mysql-number {
padding-top: 1.5em;
}
.cEdit .goto_link {
background: #EEE;
color: #555;
padding: 0.2em 0.3em;
}

View File

@ -2884,7 +2884,7 @@ span.mysql-number {
.cEdit .edit_area {
background: #FFF;
border: 1px solid #CCC;
border: 1px solid #999;
min-width: 10em;
padding: 0.3em 0.5em;
}
@ -2909,3 +2909,9 @@ span.mysql-number {
padding-top: 1.5em;
}
.cEdit .goto_link {
background: #EEE;
color: #555;
padding: 0.2em 0.3em;
}