Kendo ui grid - get data send on READ on my php -
i have seen this answer reagarding sending params on performing read operation, how access var on on php?
this code on client-side:
datasource = new kendo.data.datasource({ transport: { read: { url:"basedados.php", type: "post", datatype: "json", data: { "my_param": 1, access_token : "my_token" }, // send parameter "access_token" value "my_token" `read` request },
but on .php file, how access it?:
else { $verb = $_server["request_method"]; if ($verb == "post") { header("content-type: application/json"); if($_post['access_token']) // this? { $formdata = $_post["access_token"]; echo $formdata; }
edit: answering rick s, let show more of code:
parametermap: function(options, operation) { if (operation == "read" && options.models) { return {models: kendo.stringify(options.models)}; }; if (operation == "create" && options.models) { options.models[0].idpai = currentid; $('#gridbasedados').data('kendogrid').datasource.read(); return {models: kendo.stringify(options.models)}; }; if (operation !== "read" && options.models) { return {models: kendo.stringify(options.models)}; } }
and on server side, i(usually) had this:
else { $verb = $_server["request_method"]; if ($verb == "get") { header("content-type: application/json"); $arr = array(); $statement = $pdo->query("select a.iddocumento, a.idpai, a.tipo,a.nome,a.datacriacao, a.datamodificacao,b.nome nomeutilizadorcriador, c.nome nomeutilizadorupdate documento left outer join utilizador b on a.idutilizadorcriador=b.idutilizadores left outer join utilizador c on a.idutilizadorupdate=c.idutilizadores"); $statement->execute(); $result = $statement->fetchall(pdo::fetch_assoc); echo json_encode(array("data" => $result, "user" => $_session["user"])); }
and works, need param, because need compare "idpai".
thanks again.
you don't need post here. use parametermap option send in data.
datasource = new kendo.data.datasource({ transport: { read: { url:"basedados.php", datatype: "json", }, parametermap: function(options, operation) { return { access_token : "my_token" } } }, schema: { data: "data" }
php
$formdata = $_get["access_token"]; echo $formdata;
Comments
Post a Comment