infragistics igtree on hierarchy data - treeview

I have a data structure like this:
Node Parent Name
1 -1 Level1
2 1 Level2 - 1
3 1 Level2 - 2
4 2 Level3 - 1
5 2 Level3 - 2
6 3 Level3 - 3
....
This could lead to unlimited levels of data. and I want to use infragistics igtre to build a treeview like that.
I checked a few basic examples but not very helpful. for example:
http://help.infragistics.com/jQuery/2013.1/ui.igtree
it is limited to the pre-defined hierarchy structure.
I want to build a tree and furthermore I want to be able to add any node at any level, and move any node around.
I'm using asp.net JQUERY AJAX, infragistics control is preferred. never done mvc model.
can anyone experienced on this please send me some sample code? many thanks.

The igTree is a dynamic control and it isn't limited to a pre-defined hierarchy - granted, your model has to conform to some base schema - there's no way the control can figure out bindings on it's own, however you can share a single binding throughout the entire tree. Basically you have to look at the right place - for example I've taken this Add Remove Node API sample and with similar binding created this sample:
http://jsfiddle.net/damyanpetev/x4eAB/
What this is meant to demonstrate:
The initial Hierarchy is random (some items have additional levels) -
so you are not limited to a fixed levels for everything at start.
Adding extra nodes can be done at any level, new nodes themselves can
have multiples levels as well, so this gives you the unlimited
hierarchy you need.
When you define a single binding it is used for
subsequent levers, so all items have 'Text' property and have 'Nodes'
with more items with Text and Nodes inside and so on.
$("#tree").igTree({
bindings: {
textKey: 'Text',
valueKey: 'Text',
childDataProperty: 'Nodes'
}
});
Due to the shared binding any node can be a parent for any other, which means
that you can enable Drag and Drop with a single property and
move nodes around as you please.
I'm assuming since you want to have unlimited hierarchy your model items are similar and will easily match this case, if not you could use some LINQ to fix them up. That data structure you gave doesn't describe your model too well, so I would need some more info if this doesn't help you.

Related

Xtext disable validation from imported metamodel

I would like to know if it is possible to disable the validation for a subset of modelelements which are specified in the metamodel.
The problem is that I'm getting some validation-errors from the Xtexteditor while writting my dsl-file. So my idea is to disable the validation for exactly this modelelement.
I try to build a real simple textual notation and want to serialize the (valid) model while saving the file. The saved model is modified during the saving process, so it is
valid at the end.
Regards,
Alex
Lets beginn with the grammer:
I'am working on an imported metamodel (UML2):
import "http://www.eclipse.org/uml2/4.0.0/UML"
Then I create all the necessary parserules to define a classdiagram. In my case the problem appears
in the parserrule for associations between classes:
AssociationClass_Impl returns AssociationClass:
{AssociationClass} 'assoc' name=ID'{'
(ownedAttribute+=Property_Impl)*
'}';
And of course the parserrule for properties:
Property_Impl returns Property:
name=ID ':' type=[Type|QualifiedName]
(association=[AssociationClass|QualifiedName])?
;
Now some words to the problem itself. While editing the xtext-file in the xtexteditor of the runtime eclipse, the build model is validated. The problem is here that the metamodel itself has several constraints for an AssociationClass (screenshot not possible yet ):
Multiple markers at this line
- The feature 'memberEnd' of 'org.eclipse.uml2.uml.internal.impl.AssociationClassImpl#142edebe{platform:/resource/aaa/test.mydsl#//Has}'
with 0 values must have at least 2 values
- The feature 'relatedElement' of 'org.eclipse.uml2.uml.internal.impl.AssociationClassImpl#142edebe{platform:/resource/aaa/test.mydsl#//Has}'
with 0 values must have at least 1 values
- The feature 'endType' of 'org.eclipse.uml2.uml.internal.impl.AssociationClassImpl#142edebe{platform:/resource/aaa/test.mydsl#//Has}'
with 0 values must have at least 1 values
- An association has to have min. two ownedends.
And now I wanted to know if it is possible to disable the validation for exactly this modelelement. So I can hide the errorinformation from the user. Because I want to serialize the created xtextmodel in the next step and will do some modeltransformations.
Seems like UML registers this validator in the global singleton registry. So you basically need to avoid using the registry. You can do that by binding a different element in your runtime modul:
public EValidator.Registry bindEValidatorRegistry() {
// return an empty one as opposed to EValidator.Registry.INSTANCE
return new org.eclipse.emf.ecore.impl.ValidationDelegateRegistryImpl();
}

Getting a level of an ALV tree node?

I created an ALV TREE report, using cl_gui_alv_tree, that has 3 levels. I'm also implementing an event handler for when he double clicks a node.
My problem is that I want to take some actions only when he double clicks a node that is a root node. The event 'node_double_click' gives a node_key, but that's the index of the displayed table. How could I achieve this?
The node ID is not an index, it's the ID you assigned to the node when adding it to the tree.
If possible, I'd suggest switching to CL_SALV_TREE - not only because it is documented
and supported by SAP, but also because it comes with some query methods that are quite handy. These methods are documented as well. You can use, for example, GET_NODE to retrieve a node by its ID and then use GET_PARENT to check whether the node in question is a top-level node or has a parent node it is attached to.
I created a pattern for myself, which i am using.
lv_parent1 = node_key.
while lv_parent1 ne go_Main_tree->C_VIRTUAL_ROOT_NODE.
CALL METHOD go_main_tree->get_parent
EXPORTING
i_node_key = lv_parent1
IMPORTING
e_parent_node_key = lv_parent1.
lv_hierlevel = lv_hierlevel + 1 .
ENDWHILE.
if lv_hierlevel > 2.
“ do what You want to do
endif.

How to develop a backend for a scrum-like board

Currently I'm developing a debate module (much like a scrum/kanban board) for a GPL application (e-cidadania) and I don't have any experience with complex backends. I have developed a basic frontend for it, but now I don't know what approach I should use for the ajax and django backends to save and manipulate the table and notes.
The table can be N rows and N columns, every row and column has a name and position inside the table. Every note has also a position, text and comments (managed with the django comments framework).
I thought to store the parent element of every note (so I can place it later) and store the name of the rows and columns like CSV strings. Is that a good approach?
A screenshot of the current frontend: http: //ur1. ca/4zn4h
Update: I almost forgot, the frontend has been done with jQuery Sortables (so the user can move the note around as he likes) and CSS3.
You just need to model your domain (that is, debates that look like scrum boards) within Django. Think about it in plain English first, like this:
The has debates. These consist of criteria, organised in rows and columns in a specific order. This creates cells, which can have notes inside them.
Then you can set to work translating this into model classes. Don't worry too much about the fields they contain, the most important bit is the relationships (so the ForeignKey bits):
class Debate(models.Model):
title = ...
class Column(models.Model):
title = ...
order = ...
board = models.ForeignKey(ScrumBoard, related_name='columns')
class Row(models.Model):
title = ...
order = ...
board = models.ForeignKey(ScrumBoard, related_name='rows')
class Cell(models.Model):
column = models.ForeignKey(Column)
row = models.ForeignKey(Row)
class Note(models.Model)
text = ...
cell = models.ForeignKey(Cell)
That might be overly complex for what you need, though. I'm not an expert in the problem you're trying to solve? My suggestion, Django is quick – so start hacking, and give it a go, and if it's all wrong then you can go back a few steps, clean out your database and try again.
You might find it useful to play with South, which does database migrations for when you do things like add/remove/edit fields in your models.

How to dynamically populate fields in node form from fields of a referenced node in Drupal 6

For a project, I have a Drupal 6 site with custom contents.
The first one is the content of type A, with textfields a1, a2, ...
The second one is the content of type B, with various fields b1, b2, ... and a arbitrary number of node references to A-type nodes. The node reference is done via an autocomplete widget. Each node ref is in a fieldgroup along with textfields b'1, b'2... I want the A-type nodes to act as templates to populate these fields, without having to submit the form.
To be more direct, I want, at the moment I select the ref to the A-type node, the fields b'1,... to be populated with the content of a1,... of the referenced node.
All the fields are single lines textfields.
I've read a lot of possible solutions but I'm little lost. From what I've seen, I should use AHAH and maybe make a module. I've tried a lot of modules but none is satisfying. I'm totally new in this part of Drupal (writing modules), and I would be pleased to have any advice or direction.
Thanks!
I do not know of a module that can do this for you "out of the box". If you want to learn about module development, a good place to start is the module developers guide:
http://drupal.org/node/206753
After you've gone through the tutorial, I'd look into how you create your own content type. This tutorial will teach you about the Form API, which is what you will eventually use to create the AHAH form you need.
http://drupal.org/node/231019
Good luck!

Menu router question

My question is related to a performance issue I'm experiencing using the context module with a large number of menus. The performance issue may be a result of a module I created to import a menu structure from a different CMS into Drupal. I programatically created the menu items using menu_link_save(), passing in the menu_name, link_path (node/$nid), link_title, plid, and weight. The router_path that gets assigned to these is "node/%".
My performance issue appears to be that the context module is calling menu_link_load() for every menu item that exists (there are quite a few), and from that calling node_load() because of way the router_path is set.
In trying to troubleshoot this, I see there is a router_path of "node" in the database which has a different access_callback and access_arguments than "node/%". What is the difference between these two router_paths, how do they relate to one another, and when does one get called vs. the other?
The path 'node' shows all nodes wich are set to active&frontpage, it is also the default path for your frontpage for this reason.
The path 'node/%' is for viewing 1 specific node with id = %.

Resources