8

入力に属性を使用disabledすることで、ユーザー入力を防ぎ、わずかに異なる外観をトリガーすることができます。
これがデモhttp://jsfiddle.net/D2RLR/3023/です

テーブルのような別の TAG に同じスタイルを適用したいとしましょう。
実際、私は をhandsontable生成するために使用していExcel-like data grid editorます。次の文脈(表のようなTAG)で
どのように適用できますか?disabled attribute

これはhttp://jsfiddle.net/D2RLR/3025/handsontableを使用したデモですbootstrap

4

4 に答える 4

7

Bootstrap の既存のスタイルを適用することはできませんがinput[disabled]、スタイルを正確に模倣する新しい CSS を追加できます。

例えば:

#exampleGrid td {
    cursor: not-allowed;
    background-color: #EEE;
    color: #9E9999;
}

明らかに、これには読み取り専用ロジックが含まれておらず、フィドルでは少し奇妙に見えます(列と行のヘッダーが同じ色であるため) が、それが要点です。

于 2012-10-31T00:38:08.067 に答える
6

ここをチェックしてください:

http://handsontable.com/demo/conditional.html

.readOnlyセルのプロパティがあります-それを使用してください!

HTML入力にはreadonly、プロパティだけでなくdisabledプロパティもあります。それらの動作にはかなりの違いがあります。

于 2012-10-31T00:11:55.690 に答える
0

Boostrapは、次のような無効な属性に基づいて入力のスタイルを設定するだけです。

input[disabled], select[disabled], textarea[disabled], input[readonly], select[readonly], textarea[readonly] {
    background-color: #EEEEEE;
    cursor: not-allowed;
}

したがって、テーブルにはそのような属性がないため、ブートストラップを使用してそれを行うことはできません。

ある種のプラグインを使用するか、独自のプラグインを使用する必要があります。

于 2012-10-31T00:22:18.580 に答える
0

多分これが役立つかもしれません...セルの外観を変更し、編集できます。

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>joca@email.com</td>
            <td>(21) 9999-8888</td>
        </tr>
        <tr>
            <td>002</td>
            <td>Maria Silva</td>
            <td>mariasilva@mail.com</td>
            <td>(81) 8787-8686</td>
        </tr>
        <tr>
            <td>003</td>
            <td>José Pedro</td>
            <td>zepedro@meuemail.com</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");
        });
    });

});
于 2013-12-17T19:05:13.407 に答える