Integration server side treetable

Hi, i´m trying to create a treetable with custom script in php. i already done the data loading part (READ), now i am struggling with insert, update and delete part. I´ve tried initiate the webix with save but appears to be not working…

The webix code part is:

  view:"active_treetable",
  id:"grid",
  columns:[
        { id:"a", header:["A", {content:"textFilter"}], width:477, editor:"text", sort:"string", template:"{common.treetable()}#a#"},
        { id:"b", header:["B", {content:"selectFilter"}], width:200, sort:"date", template:"#b#"},
	{ id:"c", header:["C", {content:"selectFilter"}], width:200, sort:"date", template:"#c#"},
	{ id:"d", header:["D", {content:"selectFilter"}], width:70, sort:"int", template:"#d#"},
	{ id:"e", header:["E", {content:"selectFilter"}], width:80, editor:"text", sort:"int", template:"#e#"}
    ],
        ready:function(){
            ready_handler(this);
        },
        onClick:onclick_handler,
        scrollX:false,
        select:"row",
        navigation:true,
        editable:true,
        editaction:"dblclick",
        yCount:7,
        autowidth:true,
		save: {
				updateFromResponse:true,
				url:"data.php"
			},
		url:"data.php"
    };

The php part is:

//CONNECTS WITH DB HERE

//POST operation to be made
$webix_operation = $_POST['webix_operation'];
echo $webix_operation;

switch ($webix_operation) {
    case "insert":
        $output = "<script>console.log(123);</script>";
		echo $output;
		break;
    case "update":
        $output = "<script>console.log(456);</script>";
		echo $output;
		break;
    case "delete":
        $output = "<script>console.log(789);</script>";
		echo $output;
		break;
	default:
		//READ (HERE IS OK!)
		dataLoading($conn);
		break;
}

Hi,

when using the same server script for loading and saving, it’s better to separate logic for different types of requests, since you load data with the help of GET request (default for Webix loading) while POST request is issued during update operations:

if($_SERVER["REQUEST_METHOD"] === "GET"){
	// get data 
}
else{
	$operation = $_POST["webix_operation"];
        //and here the switch-case logic
}

We don’t have the exact example, but the saving part can be examined in this sample (Look up the server part in the package)

Many Thanks!! i will try later!! But now i have two questions.

  • First One: Can i open an empty treetable (like excel) then click on a button and save all the changes??
    -Two My client want to be one click for edition and two clicks opens a window (like Microsoft Project) from any cell, is it possible?? From what i tried it seems impossible… This is the part of the code that i am talking about in the second question.

///…
editable:true,
edictation:“custom”,
on: {
onItemClick: function (id) {
this.editCell(id[“row”],id[“column”]);
},
onItemDblClick:function(id){
var row = $$(“grid”).getItem(id);
var sit = row.sit;
var x = row.x;
var y = row.y;
var z = row.z;
var link = “example.php?a=x&b=y&c=z”;

			if(sit == 'abc'){
			   open(link);
			}		
		}},

//…