Sortorder is not working

I have set the following in the connector:

$gantt = new JSONGanttConnector($res); $gantt->mix("open", 1); $gantt->enable_order("sortorder"); //$gantt->sort("sortorder"); $gantt->render_links("gantt_links","id","source,target,type"); $gantt->render_table( "gantt_tasks", "id", "start_date,duration,text,progress,sortorder,parent,end_date,type","");

And the following in the index html:

gantt.config.order_branch = true;

Everything seems to work fine except for the sortordering of the tasks.

I could not identify any JS error.

As you can see in the picture, the values for sortorder are stored:

PS: gantt.config.sort = true; would not work either.

Please be sure that sorting is not enabled when you are using drag-reordering.
Those features are mutual exclusive

gantt.config.sort = false; gantt.config.order_branch = true;

Still won’t work…
Here is my complete code:

[code]
gantt.config.xml_date = “%Y-%m-%d %H:%i”;

	gantt.attachEvent("onTaskDrag", function(id, mode, task, original){
		   if (mode == gantt.config.drag_mode.progress)
		   {
				 task.progress = 5*(Math.round(task.progress*100/5))/100;
		   }
	});

	gantt.config.columns = [
		{name:"text",       label:"Task name",  tree:true, align: "center",resize:true},
		{name:"start_date", label:"Start date", align: "center",resize:true },
		{name:"end_date",   label:"End date",   align: "center",resize:true },
		{name:"add",        label:"",           width:44 },
	];
	
	gantt.config.grid_width = 500;
	
	gantt.config.inherit_scale_class=true;
	gantt.templates.scale_cell_class = function(date){
        if(date.getDay()==0||date.getDay()==6){
            return "weekend";
        }
    };
	
    gantt.templates.task_cell_class = function(item,date){
        if(date.getDay()==0||date.getDay()==6){
            return "weekend"
        }
    };
	function setScaleConfig(value){
	switch (value) {
			case "1":
				gantt.config.scale_unit = "day";
				gantt.config.step = 1;
				gantt.config.date_scale = "%d %M";
				gantt.config.subscales = [];
				gantt.config.scale_height = 27;
				gantt.templates.date_scale = null;
				break;
			case "2":
				var weekScaleTemplate = function(date){
					var dateToStr = gantt.date.date_to_str("%d %M");
					var endDate = gantt.date.add(gantt.date.add(date, 1, "week"), -1, "day");
					return dateToStr(date) + " - " + dateToStr(endDate);
				};

				gantt.config.scale_unit = "week";
				gantt.config.step = 1;
				gantt.templates.date_scale = weekScaleTemplate;
				gantt.config.subscales = [
					{unit:"day", step:1, date:"%D" }
				];
				gantt.config.scale_height = 50;
				break;
			case "3":
				gantt.config.scale_unit = "month";
				gantt.config.date_scale = "%F, %Y";
				gantt.config.subscales = [
					{unit:"day", step:1, date:"%j, %D" }
				];
				gantt.config.scale_height = 50;
				gantt.templates.date_scale = null;
				break;
			case "5":
				gantt.config.scale_unit = "year";
				gantt.config.step = 1;
				gantt.config.date_scale = "%Y";
				gantt.config.min_column_width = 50;

				gantt.config.scale_height = 90;
				gantt.templates.date_scale = null;
				gantt.config.subscales = [
					{unit:"month", step:1, date:"%M" }
				];
				break;
			case "4":
				gantt.config.scale_unit = "month";
				gantt.config.date_scale = "%M";
				gantt.config.subscales = [
					{unit:"week", step:1, date:"%W" }
				];
				gantt.config.scale_height = 50;
				break;
		}
	}

	setScaleConfig('5');
	
	var date_to_str = gantt.date.date_to_str(gantt.config.task_date);
 
	var id = gantt.addMarker({ start_date: new Date(), css: "today", title:date_to_str( new Date())});
	setInterval(function(){
		var today = gantt.getMarker(id);
		today.start_date = new Date();
		today.title = date_to_str(today.start_date);
		gantt.updateMarker(id);
	}, 1000*60);
	
	gantt.config.task_height = 33;
	gantt.config.row_height = 33;

	gantt.config.lightbox.sections = [
		{name: "description", height: 35, map_to: "text", type: "textarea", focus: true},
		{name: "parent", type:"parent", allow_root:"true", root_label:"No parent", filter: function(id, task){
			return true;
		}},
		{name: "period", map_to:"auto", type:"time"},
		{name: "type", type: "typeselect", map_to: "type"},
	];
	
	gantt.locale.labels.section_period = "Time period";
	gantt.locale.labels["section_parent"] = "Parent task";
	gantt.locale.labels.section_sortorder = "Sortorder";
	gantt.locale.labels["complete_button"] = "Complete";
	gantt.config.buttons_left=["dhx_save_btn","dhx_cancel_btn","complete_button"];

	gantt.templates.task_class=function(start,end,task){
		if (task.progress == 1)
			return "completed_task";
		return "";
	};
	
	gantt.templates.rightside_text = function(start, end, task){
		if(task.type == gantt.config.types.milestone){
			return task.text;
		}
		return "";
	};
	
	gantt.config.grid_resize = true;
	gantt.config.keep_grid_width = true; 
	
	gantt.templates.progress_text = function(start, end, task){
		return "<span style='text-align:left;'>"+Math.round(task.progress*100)+ "% </span>";
	};
	
	gantt.config.order_branch = true;
	gantt.config.sort = false;
	
    gantt.init("gantt_here");   
	gantt.load('database.php');//loads data to Gantt from the database
	var dp=new dataProcessor("database.php");   
	dp.init(gantt);
	
	var func = function(e) {
		e = e || window.event;
		var el = e.target || e.srcElement;
		var value = el.value;
		setScaleConfig(value);
		gantt.render();
	};

	var els = document.getElementsByName("scale");
	for (var i = 0; i < els.length; i++) {
		els[i].onclick = func;
	}

	gantt.attachEvent("onLightboxButton", function(button_id, node, e){
		if(button_id == "complete_button"){
			var id = gantt.getState().lightbox;
			gantt.getTask(id).progress = 1;
			gantt.updateTask(id)
			gantt.hideLightbox();
		}
	});
	gantt.attachEvent("onBeforeLightbox", function(id) {
		var task = gantt.getTask(id);
		if (task.progress == 1){
			dhtmlx.message({text:"The task is already completed!", type:"completed"});
		}
		return true;
	});
	
</script>[/code]

Sorry for double post. But it seems that the order is determined by the value of id. :question:

This is the result of the log:

[code]====================================
Log started, 04/05/2015 12:15:30

SELECT id,start_date,duration,text,progress,sortorder,parent,end_date,type FROM gantt_tasks ORDER BY sortorder

SELECT id,source,target,type FROM gantt_links

Done in 0.0025599002838135s[/code]

I deeply apologize for posting so much, but I could not find any “edit” functionality. The mods can ofcourse sum up my posts into one if necessary.

A Temporary solution would be this input:

<input type='button' class="input_export" value='Sort by Order' onclick='gantt.sort("sortorder", true);'>

I can confirm issue for the Gantt 3.2
Please try to update Gantt to the latest version - 3.2.1, it contains a fix for the above issue.