I want to add a attribute (for example title="UID"... ) to the new node, but it dosen't work. I need the title attribute, because in my project there are 3 Typs off nodes:
1. K_56gS5sa K_ = Typ = Catalog 2. C_ HG52s2 C_ = Typ = Category3. P_65jgsG4 P_ = Typ = Product
I want to manipulation attributes or set new attributes of a new node.
Here the example Code:
<asp:UpdatePanel ID="UpdatepanelTreeview" runat="server" UpdateMode="Conditional"
ChildrenAsTriggers="true">
<ContentTemplate>
<ig:WebDataTree ID="DDWebDataTree" runat="server" StyleSetName="RedPlanet"
SelectionType="Single"
EnableAjax="true"
CheckBoxMode="Off"
EnableConnectorLines="true"
EnableAutoChecking="true"
EnableAjaxViewState="true"
OnNodeDropped="DDWebDataTree_NodeDropped"
OnNodeClick="DDWebDataTree__NodeClick"
ClientEvents-DragStart="GetParent"
NodeSettings-ParentNodeImageUrl="~/theme/images/tools/catalog.png"
NodeSettings-LeafNodeImageUrl="~/theme/images/tools/category.png"
NodeSettings-ImageUrl="~/theme/images/tools/product.png"
DataLoadingMessage="...loading"
ViewStateMode="Enabled" >
<DragDropSettings AllowDrop="true" EnableDragDrop="true">
</DragDropSettings>
<AutoPostBackFlags
NodeDropped="On"
NodeAdded="On"
NodeRemoved="On"
NodeClick="On"
NodeEditingTextChanged="On" />
</ig:WebDataTree>
<asp:HiddenField ID="HF_Parent" runat="server" Value="" />
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="DDWebDataTree" />
</Triggers>
</asp:UpdatePanel>
<script>
function addNode(sUID, sName, iTyp) {
//var nodeText = textBoxNewNode.value;
var nodeText = sName;
textBoxNewNode.value = "";
if (isNullorUndefined(nodeText) || (nodeText == "")) {
alert("You have to specify a node name.");
return false;
}
var parent = currentTree.get_selectedNodes();
var location;
if ((!isNullorUndefined(parent)) && (parent.length > 0)) {
location = $adrutil.getLocationFromDomElement(parent[0].get_element());
var node = currentTree.createNode(nodeText);
node.set_valueString(sUID);
node.set_id(sUID);
//node.setAttribute("title", sUID);
node._element.setAttribute("title", sUID)
if (!isNullorUndefined(location)) {
currentTree.add(node, location);
else {
currentTree.add(node, null);
Hi,
Can you make sure that
DAKOGOERLICH said:node._element.setAttribute("title", 'myTitle');
node is returned by add function like this:
Then you can use the instance returned by add method to add some attributes to it to be rendered.
Sorry, it dosen't work. In the moment of ...
node._element.setAttribute("title", 'myTitle'); currentTree.add(node, location);
}no title is there!
after ... currentTree.add(node, location) you see the new node in den tree but without the title attribute!
Best regards,
Hi DAKOGOERLICH,
I've been looking at your code and ti seems fine, the reason why the attribute was not added to the dom element is because when you call add method and pass the newly created tree node by reference it's been copied and all operations performed on the firstly created node are not reflected to the one based on which the dom elements are being rendered. The solution is as simple as this:
Hope this helps a bit.