当前位置: 动力学知识库 > 问答 > 编程问答 >

How Can Set Icon for each node by c# Ajax Response in Jstree?

问题描述:

How Can Set Icon for each node by c# Ajax Response in Jstree?

in this line see Ajax jstree :

Webmethod is not fired by jsTree

the ajax jstree successfully run, but how can show Icon for each node ?

in this line :

_GG_JSTree.icons = ""; How Can set icons?

 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;

}

网友答案:

Take a look at the format spec:
https://github.com/vakata/jstree#the-required-json-format

  • The property name is icon, not icons.
    ( state should be an object, no a string, etc.

As for the icon property it is explained in the above link:

icon - a string which will be used for the node's icon - this can either be a path to a file, or a className (or list of classNames), which you can style in your CSS (font icons also work).

Basically - just take a deeper look at the docs and you should be fine.

网友答案:

try following

_GG_JSTree.icon = "glyphicon glyphicon-heart"; 

if u use bootstrap to show heart icon

'icon' defined in 'Type' plugin section may override this.

分享给朋友:
您可能感兴趣的文章:
随机阅读: