如何在Jstree中通过c#Ajax响应为每个节点设置图标?

时间:2015-08-02 11:00:03

标签: ajax jstree

如何在Jstree中通过c#Ajax响应为每个节点设置图标? 在这一行中看到Ajax jstree: Webmethod is not fired by jsTree ajax jstree成功运行,但是如何为每个节点显示Icon? 在这一行: _GG_JSTree.icons ="&#34 ;;如何设置图标?

 private static List<GG_JSTree> AddChildNodes(int _ParentID, int NumOfChildren, string ParentName)
{
    List<GG_JSTree> GG_JSTreeArray = new List<GG_JSTree>();
    int n = 10;
    for (int i = 0; i < NumOfChildren; i++)
    {
        int CurrChildId = (_ParentID == 0) ? n : ((_ParentID * 10) + i);
        GG_JSTree _GG_JSTree = new GG_JSTree();
        _GG_JSTree.data = (_ParentID == 0) ? "root" + "-Child" + i.ToString() : ParentName + CurrChildId.ToString() + i.ToString();
        _GG_JSTree.state = "closed";  //For async to work
        _GG_JSTree.icons = "";   How Can set?
        _GG_JSTree.IdServerUse = (int)CurrChildId;
        _GG_JSTree.children = null;
        _GG_JSTree.attr = new GG_JSTreeAttribute { id = CurrChildId.ToString(), selected = false };
        GG_JSTreeArray.Add(_GG_JSTree);
        n = n + 10;
    }

    return GG_JSTreeArray;
}

2 个答案:

答案 0 :(得分:0)

看一下格式规格:
https://github.com/vakata/jstree#the-required-json-format

  • 属性名称为icon,而不是iconsstate应该是一个对象,不是字符串等。

至于icon属性,将在上面的链接中解释:

  

icon - 将用于节点图标的字符串 - 这可以是文件的路径,也可以是className(或classNames列表),您可以在其中设置样式CSS(字体图标也有效)。

基本上 - 只需深入了解一下文档即可,你应该没事。

答案 1 :(得分:0)

尝试以下

_GG_JSTree.icon = "glyphicon glyphicon-heart"; 

如果你使用bootstrap显示心脏图标

&#39;图标&#39;在&#39; Type&#39;中定义插件部分可能会覆盖此。

相关问题