I'm having some trouble getting my nested listviews to sort properly. I have a parent list view that can have 1+ child listviews. I want to be able to sort each listview individually, eg. be able to sort all of the children inside of their parent.
Here is what I currently have for the parent listview and then all of the child of it:
$(
"#baSurveyGroupTemplateListView"
).kendoSortable({
handler:
".handle"
,
connectWith:
".childBaSurveyGroupTemplate"
,
filter:
"> .baSurveyGroupPanel"
,
axis:
"y"
,
cursor:
"move"
,
hint:
function
(element) {
return
element.clone().addClass(
"hint"
);
}
placeHolder:
function
(element) {
return
element.clone().addClass(
"policy-section-panel-placeholder"
).text(
"Drop Here!"
);
},
change:
function
(e) {
alert(e.oldIndex);
alert(e.newIndex);
},
ignore:
".childBaSurveyGroupTemplate >.baSurveyGroupPanel"
,
autoScroll:
true
});
$(
".childBaSurveyGroupTemplate"
).kendoSortable({
handler:
".test-handle"
,
connectWith:
"#baSurveyGroupTemplateListView"
,
filter:
"> .baSurveyGroupPanel"
,
axis:
"y"
,
cursor:
"move"
,
hint:
function
(element) {
return
element.clone().addClass(
"hint"
);
},
placeholder:
function
(element) {
return
element.clone().addClass(
"policy-section-panel-placeholder"
).text(
"Drop Here!"
);
},
autoScroll:
true
});
Here is a simple breakdown of the HTML structure with a Parent ListView followed by two child listviews:
<
div
id
=
"baSurveyGroupTemplateListView"
>
<
div
class
=
"panel panel-default baSurveyGroupPanel"
>
<
div
class
=
"panel-heading"
>
<
h4
class
=
"panel-title"
>Title</
h4
>
</
div
>
<
div
class
=
"panel-body"
>
<
div
class
=
"childBaSurveyGroupTemplate"
>
<
div
class
=
"panel panel-default baSurveyGroupPanel"
>
<
div
class
=
"panel-heading"
>
<
h4
class
=
"panel-title"
>Title</
h4
>
</
div
>
</
div
>
<
div
class
=
"panel panel-default baSurveyGroupPanel"
>
<
div
class
=
"panel-heading"
>
<
h4
class
=
"panel-title"
>Title</
h4
>
</
div
>
</
div
>
</
div
>
</
div
>
</
div
>
<
div
class
=
"panel panel-default baSurveyGroupPanel"
>
<
div
class
=
"panel-heading"
>
<
h4
class
=
"panel-title"
>Title</
h4
>
</
div
>
<
div
class
=
"panel-body"
>
<
div
class
=
"childBaSurveyGroupTemplate"
>
<
div
class
=
"panel panel-default baSurveyGroupPanel"
>
<
div
class
=
"panel-heading"
>
<
h4
class
=
"panel-title"
>Title</
h4
>
</
div
>
</
div
>
<
div
class
=
"panel panel-default baSurveyGroupPanel"
>
<
div
class
=
"panel-heading"
>
<
h4
class
=
"panel-title"
>Title</
h4
>
</
div
>
</
div
>
</
div
>
</
div
>
</
div
>
</
div
>
So my goal here is to be able to sort each child within its parent. With the current JavaScript I am able to successfully sort the child panels of the #baSurveyGroupTemplateListView but when I try and sort the child panels of the .childBaSurveyGroupTemplate ListViews it ends up just moving the parent ListView.
I thought by telling the #baSurveyGroupTemplateListView to ignore ".childBaSurveyGroupTemplate >.baSurveyGroupPanel" and to filter "> .baSurveyGroupPanel" that I would be able to sort the children separately but that doesn't seem to be the case here.