简体   繁体   English

phpgrid-更改编辑路径

[英]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. 我在Slim Framework集成中使用phpgrid ,并且看到phpgrid系统的所有编辑和创建功能都将数据发送到位于phpgrid文件夹内的名为“ edit.php”的文件中。

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? 我有什么办法可以改变它,并将表单的结果实际路由到另一个文件,最好是Slim中的控制器?

LE: It's worth to mention that I am not using a DB connection to process the data. LE:值得一提的是,我没有使用数据库连接来处理数据。 Instead, I use an API to fetch and process my data, and I feed the data to phpgrid in an array. 取而代之的是,我使用API​​来获取和处理我的数据,然后将数据以数组的形式提供给phpgrid。

Google "phpgrid save local array" gives this post 谷歌“ phpgrid保存本地数组”给出了这篇文章

Save Local Data Array Back to Server via Ajax 通过Ajax将本地数据阵列保存回服务器

You can use submit the changes in jQuery ajax post to whatever url of your choice 您可以使用将jQuery ajax帖子中的更改提交到您选择的任何url

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() . 它表明,在对文档进行更仔细的检查时,有一个名为set_js_editurl()的方法,该文档隐藏在无法清晰搜索的地方。

This method lets you set your own URL and everything else works the same :) 此方法使您可以设置自己的URL,其他所有功能都相同:)

Happy coding, Ares D. 祝您编码愉快,战神D。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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