8

データベースから構成可能なjstreeが必要で、アイコンに問題があります(これは、アイコンの名前を含むクエリの別の列です)。問題は、正しく表示できないことです。

ここに画像の説明を入力

background-image:url('path');タグ内の画像を指す属性を追加してこのリストを作成し<a>ますが、そのフォルダー アイコンが表示され続けます (画像は繰り返されませんが、問題を簡単に視覚化するために含めます)。

そのフォルダを表示しないようにjstreeを作成するにはどうすればよいですか? jstree は、ツリー全体 (または少なくとも各レベル) に対して 1 つのイメージを作成するだけのようです。それを変更する方法がわかりません。

上の画像のhtmlです。

<ul style=""><li id="1227_1226" class="leaf jstree-leaf">
<ins class="jstree-icon">&nbsp;</ins>
            <a href="/arco/formatos/Estrategia desarrollo.doc" style="background-image:url('/arco/Menu/images/web.png;');" class="nothing"><ins class="jstree-icon">&nbsp;</ins>
                Instructivo desarrollo
            </a>
        </li>

        <li id="1227_1228" class="leaf jstree-leaf"><ins class="jstree-icon">&nbsp;</ins>
            <a href="/arco/formatos/FO-0001 FormatoMantenimientoPlanificado-V1.doc" style="background-image:url('/arco/Menu/images/web.png;');" class="nothing"><ins class="jstree-icon">&nbsp;</ins>
                Mantenimiento planificado
            </a>
        </li>

        <li id="1227_1229" class="leaf"><ins class="jstree-icon">&nbsp;</ins>
            <a href="/arco/formatos/FO-0002 FormatoAnalisisRequisitos.doc" style="background-image:url('/arco/Menu/images/web.png;');" class="nothing"><ins class="jstree-icon">&nbsp;</ins>
                Análisis de requisitos
            </a>
        </li>

        <li id="1227_1230" class="leaf jstree-leaf"><ins class="jstree-icon">&nbsp;</ins>
            <a href="/arco/formatos/FO-0003 FormatoInstructivoInstalacion.doc" style="background-image:url('/arco/Menu/images/web.png;');" class="nothing"><ins class="jstree-icon">&nbsp;</ins>
                Instructivo de instalación
            </a>
        </li>

        <li id="1227_1231" class="leaf jstree-leaf"><ins class="jstree-icon">&nbsp;</ins>
            <a href="/arco/formatos/FO-0004 FormatoControlCalidadConstruccion.doc" style="background-image:url('/arco/Menu/images/web.png;');" class="nothing"><ins class="jstree-icon">&nbsp;</ins>
                Control de calidad
            </a>
        </li>

        <li id="1227_1232" class="leaf jstree-leaf"><ins class="jstree-icon">&nbsp;</ins>
            <a href="/arco/formatos/FO-0005 FormatoPruebasUsuario.doc" style="background-image:url('/arco/Menu/images/web.png;');" class="nothing"><ins class="jstree-icon">&nbsp;</ins>
                Pruebas de usuario
            </a>
        </li>

        <li id="1227_1233" class="leaf jstree-leaf"><ins class="jstree-icon">&nbsp;</ins>
            <a href="/arco/formatos/FO-0007 FormatoActas-V1.doc" style="background-image:url('/arco/Menu/images/web.png;');" class="nothing"><ins class="jstree-icon">&nbsp;</ins>
                Actas
            </a>
        </li>

        <li id="1227_1263" class="leaf jstree-last jstree-leaf"><ins class="jstree-icon">&nbsp;</ins>
            <a href="/arco/formatos/FO-0006 FormatoSolicitudSoporte V1.doc" style="background-image:url('/arco/Menu/images/web.png;');" class="nothing"><ins class="jstree-icon">&nbsp;</ins>
                Solicitud de soporte
            </a>
        </li></ul>

これが私がツリーを構築する方法です。ajax 呼び出しは、html リストを受け取ります。

$(function () {
    $("#arbolMenu").jstree({ 
        "plugins" : [ "themes", "html_data", "cookies"], 
        "html_data" : {
            "ajax" : {
                "url" : "/arco/CtrlMenu",
                "data" : function (n) {
                    return { id : n.attr ? n.attr("id") : -1 };
                }
            }
        }
    });
}).delegate(".jstree-open>a", "click.jstree", function(event){
    $.jstree._reference(this).close_node(this, false, false);
}).delegate(".jstree-closed>a", "click.jstree", function(event){
    $.jstree._reference(this).open_node(this, false, false);
});
4

2 に答える 2

9

アイコンを明示的に指定するのではなく、 jstree に付属のタイプ プラグインを使用します。次に<li>、html のそれぞれについて、そのrelプロパティを定義したタイプに割り当てます。簡単な例を次に示します。

$(function () {
    $("#demo1").jstree({ 
        "types" : {
            "valid_children" : [ "web" ],
            "types" : {
                "web" : {
                    "icon" : { 
                        "image" : "/arco/Menu/images/web.png" 
                    },
                },
                "default" : {
                    "valid_children" : [ "default" ]
                }
            }
        },
        "plugins" : ["themes","html_data","dnd","ui","types"]
    });
});

ツリー ノード html のサンプル スニペットを次に示します。

<li id="1227_1228" rel="web">
    <a href="some_value_here">Mantenimiento planificado</a>
    <!-- UL node only needed for children - omit if there are no children -->
    <ul>
        <!-- Children LI nodes here -->
    </ul>
</li>

を指定rel="web"したため<li><li>は typewebに定義されたプロパティを受け取ります。これには、上で定義したカスタム アイコンが含まれます。

詳細については、公式の jstree ドキュメントを参照してください。

于 2012-08-03T18:23:01.863 に答える
0

ドキュメントに次の CSS を追加します。

.jstree-icon {
    display: none;
}
于 2012-08-03T15:48:43.887 に答える