어쩌면이게 도움이 될 수 있습니다 ... 세포의 모양을 변경하고 그것에 편집 할 수 있습니다.
HTML
<table class="editableTable">
<thead>
<tr>
<th>Code</th>
<th>Name</th>
<th>E-mail</th>
<th>Telephone</th>
</tr>
</thead>
<tbody>
<tr>
<td>001</td>
<td>João Carlos</td>
<td>[email protected]</td>
<td>(21) 9999-8888</td>
</tr>
<tr>
<td>002</td>
<td>Maria Silva</td>
<td>[email protected]</td>
<td>(81) 8787-8686</td>
</tr>
<tr>
<td>003</td>
<td>José Pedro</td>
<td>[email protected]</td>
<td>(84) 3232-3232</td>
</tr>
</tbody>
</table>
CSS
* {
font-family: Consolas;
}
.editableTable {
border: solid 1px;
width: 100%
}
.editableTable td {
border: solid 1px;
}
.editableTable .editingCell {
padding: 0;
}
.editableTable .editingCell input[type=text] {
width: 100%;
border: 0;
background-color: rgb(255,253,210);
}
JS
$(function() {
$("td").dblclick(function() {
var originalContent = $(this).text();
$(this).addClass("editingCell");
$(this).html("<input type='text' value='" + originalContent + "' />");
$(this).children().first().focus();
$(this).children().first().keypress(function (e) {
if (e.which == 13) {
var newContent = $(this).val();
$(this).parent().text(newContent);
$(this).parent().removeClass("editingCell");
}
});
$(this).children().first().blur(function(){
$(this).parent().text(originalContent);
$(this).parent().removeClass("editingCell");
});
});
});
플러그인 것과 같은, 그렇게 할 몇 가지 옵션을 가지고 있지 않는 당신이 할 수없는 그냥 r 파란색 테두리와 모든 것으로 움직이는 egular 요소. 가장 가까운 것은 플러그인에서 이벤트를 무시하거나 자신 만의 플러그인을 만드는 것입니다. – adeneo
@adeneo 귀하의 의견에 감사드립니다. 어쨌든, 나는 테이블에'disabled attribute'를 적용해서는 안되지만, 손 잡을 수있는 데이터 그리드에 속한 셀을 클릭 할 때 입력 폼에 그것을 적용하는 방법을 찾아야합니다. 어떻게 만드는지? –