Page 1 of 1

Auto Save Edit Grid

Posted: Tue Sep 27, 2022 4:15 am
by juniorpinto

I'm making a checklist and I need the information to be saved in the database as I tick the radio button. I believe I should do it with Ajax. Can anyone guide me? Thanks


Re: Auto Save Edit Grid

Posted: Tue Sep 27, 2022 8:51 am
by arbei

Yes, you can, you may read Create Your Own API Action.


Re: Auto Save Edit Grid

Posted: Wed Sep 28, 2022 1:15 am
by juniorpinto

In: Server Events / Global / All Pages / Api_Action, i have create a script....

// API Action event
function Api_Action($app){

    $app->get('/CheckList/{Relatorio}/{Questao}/{Valor}', function ($request, $response, $args){

        $Relatorio = $args["Relatorio"];
        $Questao = $args["Questao"];
        $ValorClicado = $args["Valor"];

        $myResult = ExecuteStatement("UPDATE tb_itensavaliados SET Resultado='{$ValorClicado}' WHERE CodRel= {$Relatorio} and CodQuetoes= {$Questao}");

        return $response;

    });
}

I thought of calling it in Edit Tag Client side events... but I don't know how... the path is: /api/CheckList/1/9/BA


Re: Auto Save Edit Grid

Posted: Wed Sep 28, 2022 3:45 am
by juniorpinto

sorted out!!!!
to call the api I put it in Edit Tag / Client side events:

{ // keys = event types, values = handler functions
	"change": function(e) {
		var $parameter1 = "xxxxx";
                var $parameter2 = "xxxxx";
                var $parameter3 = "xxxxx";

fetch("./api/CheckList/" + $parameter1 + "/" + $parameter2 + "/" + $parameter3);

	}
}