EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: wel on January 14, 2016, 05:23:32 PM



Title: pass current selected record data in a grid to another php file
Post by: wel on January 14, 2016, 05:23:32 PM
I use inline grid and I need to pass all the fields values of the current selected record to another php file and same time navigate to this page so I can read values like this:

$myvar = $_REQUEST['field'];

So I added new button on the grid tool bar like this:
Code:
<a href="#" class="easyui-linkbutton" iconCls="icon-more" plain="true" onclick="getSelected()">Detail Page</a>

And the script was like this

Code:
<script type="text/javascript">
    function getSelected(){
        var row = $('#dg').datagrid('getSelected');
        if (row){
            window.location = 'job_detail.php?jd='+row.job_message_id;
</script>

I dont want to pass about 15 fields in a GET way so is there a way to POST all values to job_detail.php page ?


Title: Re: pass current selected record data in a grid to another php file
Post by: wel on January 17, 2016, 11:31:25 AM
I can read the id and then select from the db all fields again but I was wondering if datagrid can pass the row object with all values to another php page or not ?.


Title: Re: pass current selected record data in a grid to another php file
Post by: jarry on January 17, 2016, 06:41:42 PM
Please try this code to post the selected row to your server.
Code:
var row = $('#dg').datagrid('getSelected');
if (row){
$.post(url, row, fucntion(){
//...
})
}


Title: Re: pass current selected record data in a grid to another php file
Post by: wel on January 17, 2016, 06:53:49 PM
Thanks I tried JQuery post and it really post row to another php page (ex detail.php) but the problem I still stay at the grid page I need to also to move to this new page detail.php to simply display the grid current selected record in a form style, any idea ?


Title: Re: pass current selected record data in a grid to another php file
Post by: jarry on January 17, 2016, 10:53:30 PM
You can't send a post to server by using 'location.href'.


Title: Re: pass current selected record data in a grid to another php file
Post by: wel on January 18, 2016, 08:01:03 AM
Is there any method to send row object to detail.php page and also move to this page ?


Title: Re: pass current selected record data in a grid to another php file
Post by: wel on January 18, 2016, 12:11:33 PM
I found a way , I used cookies and then read the data using json_decode.