简体   繁体   中英

phpgrid - change edit route

I am using phpgrid in a Slim Framework integration and I see all the editing and creating functionality of the phpgrid system sends the data to a file called "edit.php" that sits inside the phpgrid folder.

Is there any way that I can change that and actually route the result of the form to a different file, preferably a controller in Slim?

LE: It's worth to mention that I am not using a DB connection to process the data. Instead, I use an API to fetch and process my data, and I feed the data to phpgrid in an array.

Google "phpgrid save local array" gives this post

Save Local Data Array Back to Server via Ajax

You can use submit the changes in jQuery ajax post to whatever url of your choice

Demo

<script src="http://malsup.github.com/jquery.form.js"></script>
<form id="admin_form">
    <div>
        <input type="submit" value="Submit Local Changes">
    </div>
</form>

<script>
    $(function() {
        // bind to the form's submit event
        $('#admin_form').submit(function(event) {
            $(this).ajaxSubmit({
                type: 'post',
                dataType:'json',
                url:'save_local_array.php',
                data:{
                    langArray:[] //leave as empty array here
                },
                beforeSubmit: function(arr, $form, options){
                    options.langArray = $('#data1').jqGrid('getRowData'); //current
                    console.log(JSON.stringify(options.langArray));
                    // return false; // here to prevent submit
                },
                success: function(){
                    // add routine here when success
                }
            });

            // return false to prevent normal browser submit and page navigation
            return false;
        });
    });
</script>

It seams that on closer inspection to the documentation, somewhere hidden without the ability to clearly search for it, there is a method called: set_js_editurl() .

This method lets you set your own URL and everything else works the same :)

Happy coding, Ares D.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM