Reputation: 5774
I am trying to make a nested sortable list (nesting up to 2 level only). I tried using RP Neimeyers sortable plugin but I need some more functionality like
What I have achieved so far -
I am stuck on : 1. Maintaining indexing for sub items 2. Ability to convert main item a sub item and vice versa.
My attempt on JSFiddle : http://jsfiddle.net/83QrY/
All the code is given in KnockoutJS..
I am using self.Tasks.withIndex("Position", 0, 0);
to maintain indexing. I hope someone will definitely help me on achieving this..
PS : I am not asking the solution, I want some help on achieving this. I also need to learn it :-)
Regards. RP.
Upvotes: 0
Views: 219
Reputation: 114792
Here are a few tips:
connectClass
option determines which sortables can drag and drop with each other. The top-level sortable has it set to "Tasks", which prevents the SubTasks
lists from being able to interoperate with the parents. So, you could remove the connectClass
option from the parent to allow dropping between parent/childTaskModel
that supports all of your observable properties that you could use for Tasks and Sub-Tasks. Otherwise, you could use the beforeMove
callback to map arg.item
to the correct format, splice it manually (using arg.TargetParent
and arg.TargetIndex
), then set arg.cancelDrop
equal to true.withIndex
extension is a way that I like to maintain the index. In the TaskModel
constructor, you can create the SubTasks
observableArray with the indexing added. Otherwise, you could have to use the mapping options of the mapping plugin to try to make that happen.beforeMove
to extract the Sub-Tasks.Here is a sample with the first 3 updates: http://jsfiddle.net/rniemeyer/5V3rK/
Upvotes: 1