I have a tree with folder nodes only on it. These nodes can be dragged
and dropped on each other. I want to limit the tree to be only two
levels deep, and so any drag-and-drop attempts which would make the
tree more deep would be disallowed. Is there a method to accomplish
this with the current featureset of jsTree 0.9.6?
> I have a tree with folder nodes only on it. These nodes can be dragged
> and dropped on each other. I want to limit the tree to be only two
> levels deep, and so any drag-and-drop attempts which would make the
> tree more deep would be disallowed. Is there a method to accomplish
> this with the current featureset of jsTree 0.9.6?
Ok, that was dumb on my part not to look first. Sorry.
However, I looked on the examples. The difference is that I'm using
async JSON as source, and it doesn't seem to work. Here it is the JSON
response for the top level objects:
([
{
attributes: {id: 1},
state: 'closed',
data: 'Electronics',
mdata: { type: 'file', max_depth : 2 }
},
{
attributes: {id: 6},
state: 'closed',
data: 'Portable electronics',
mdata: { type: 'folder', max_depth : 2 }
}
])
In the rules attribute of the configuration I set metadata: "mdata".
Oh, and the metadata jquery plugin is loaded.
The problem is that it doesn't work at all. Even if I change the type
to file it doesn't show any difference.
Most probably I made some mistakes on the metadata part, but can't
figure it out what exactly.
On Apr 8, 6:16 pm, vakata <ivan.bozha...@gmail.com> wrote:
> Yes, check the metadata (under "others" on the examples page) examples
> - what you are looking for is "max_depth".
> Best regards,
> Ivan
> On 8 Апр, 17:02, boteeka <bote...@gmail.com> wrote:
> > I have a tree with folder nodes only on it. These nodes can be dragged
> > and dropped on each other. I want to limit the tree to be only two
> > levels deep, and so any drag-and-drop attempts which would make the
> > tree more deep would be disallowed. Is there a method to accomplish
> > this with the current featureset of jsTree 0.9.6?
> Ok, that was dumb on my part not to look first. Sorry.
> However, I looked on the examples. The difference is that I'm using
> async JSON as source, and it doesn't seem to work. Here it is the JSON
> response for the top level objects:
> ([
> {
> attributes: {id: 1},
> state: 'closed',
> data: 'Electronics',
> mdata: { type: 'file', max_depth : 2 }
> },
> {
> attributes: {id: 6},
> state: 'closed',
> data: 'Portable electronics',
> mdata: { type: 'folder', max_depth : 2 }
> }
> ])
> In the rules attribute of the configuration I set metadata: "mdata".
> Oh, and the metadata jquery plugin is loaded.
> The problem is that it doesn't work at all. Even if I change the type
> to file it doesn't show any difference.
> Most probably I made some mistakes on the metadata part, but can't
> figure it out what exactly.
> On Apr 8, 6:16 pm, vakata <ivan.bozha...@gmail.com> wrote:
> > Yes, check the metadata (under "others" on the examples page) examples
> > - what you are looking for is "max_depth".
> > Best regards,
> > Ivan
> > On 8 Апр, 17:02, boteeka <bote...@gmail.com> wrote:
> > > I have a tree with folder nodes only on it. These nodes can be dragged
> > > and dropped on each other. I want to limit the tree to be only two
> > > levels deep, and so any drag-and-drop attempts which would make the
> > > tree more deep would be disallowed. Is there a method to accomplish
> > > this with the current featureset of jsTree 0.9.6?
Thanks for your guidance. I finally worked out. But I found that your
example does not work:
...
{
attributes: {id: 1, mdata : "{ type: 'file', max_depth : 2
> Basically you need this type of structure:
> ...
> {
> attributes: {id: 1, mdata : "{ type: 'file',
> max_depth : 2 }" },
> state: 'closed',
> data: 'Electronics'
> },
> ...
> mdata becomes part of the attributes and its value is a string.
> I hope this helps!
> Best regards,
> Ivan
> On 9 Апр, 10:44, boteeka <bote...@gmail.com> wrote:
> > Ok, that was dumb on my part not to look first. Sorry.
> > However, I looked on the examples. The difference is that I'm using
> > async JSON as source, and it doesn't seem to work. Here it is the JSON
> > response for the top level objects:
> > ([
> > {
> > attributes: {id: 1},
> > state: 'closed',
> > data: 'Electronics',
> > mdata: { type: 'file', max_depth : 2 }
> > },
> > {
> > attributes: {id: 6},
> > state: 'closed',
> > data: 'Portable electronics',
> > mdata: { type: 'folder', max_depth : 2 }
> > }
> > ])
> > In the rules attribute of the configuration I set metadata: "mdata".
> > Oh, and the metadata jquery plugin is loaded.
> > The problem is that it doesn't work at all. Even if I change the type
> > to file it doesn't show any difference.
> > Most probably I made some mistakes on the metadata part, but can't
> > figure it out what exactly.
> > On Apr 8, 6:16 pm, vakata <ivan.bozha...@gmail.com> wrote:
> > > Yes, check the metadata (under "others" on the examples page) examples
> > > - what you are looking for is "max_depth".
> > > Best regards,
> > > Ivan
> > > On 8 Апр, 17:02, boteeka <bote...@gmail.com> wrote:
> > > > I have a tree with folder nodes only on it. These nodes can be
> dragged
> > > > and dropped on each other. I want to limit the tree to be only two
> > > > levels deep, and so any drag-and-drop attempts which would make the
> > > > tree more deep would be disallowed. Is there a method to accomplish
> > > > this with the current featureset of jsTree 0.9.6?
-- Szász Botond
e-mail: bote...@gmail.com,
bote...@yahoo.com
tel.: +40744303363