|
Title: datagrid calls form: how to pass id paramater Post by: andyj on July 30, 2013, 02:12:13 AM I want to call a form to edit a single record from a datagrid containing many records.
The edit form's datasource (data_select.php) dynamically queries a MySQL table to create a json file. It needs to receive the id key parameter. e.g. data_select.php?entity_id=3 (where 3 is the parameter value being passed) Code: <?php include '../../common/conn.php'; $eid = intval($_REQUEST['entity_id']); $rs = mysql_query("SELECT entity_id, FirstName, MiddleName, LastName,Suffix,Phone,Mobile,AltPhone,Fax,Email FROM entity WHERE entity_id = $eid"); $items = array(); while($row = mysql_fetch_object($rs)){ array_push($items, $row); } $result["row"] = $items; echo str_replace( array( '[', ']'), '', json_encode($items)); ?> The calling datagrid uses this function to open the edit form: Code: function openForm(){ This seems to work finevar row = $('#dg').datagrid('getSelected'); if (row) { url = "../supplieredit/supplieredit.php?entity_id=" + row.entity_id; window.open(url,'_parent'); } } The edit form itself has its datasource definition like this: Code: $('#fm1').form('load','data_select.php?entity_id='+request.getParameter("entity_id")); But it is not getting the parameter (herein lies the problem I think).Can anyone help please? Thanks in advance :-\ Title: Re: datagrid calls form: how to pass id paramater Post by: stworthy on July 30, 2013, 06:45:32 PM Some syntax errors occur in your statement:
Code: $('#fm1').form('load','data_select.php?entity_id='+request.getParameter("entity_id")); If the 'entity_id' is generated from your php file, please use the code below.Code: $('#fm1').form('load','data_select.php?entity_id='+'<?php echo $eid;?>'); Title: Re: datagrid calls form: how to pass id paramater Post by: andyj on July 31, 2013, 01:33:16 AM Unfortunately that didn't do the trick.
Code: $('#fm1').form('load','data_select.php?entity_id='+'<?php echo $eid;?>'); Doesn't get the parameter value of "entity_id" and add it to the url.View Source shows a blank value, e.g. "supplieredit.php?entity_id=" The order of events is
My only thoughts on why it is not working are: May be the edit form's "load" method is firing before the url parameter is available to it? Should I use the form's onBeforeLoad method to get the variable? Is there any tutorial on how to pass variables via url parameters? I guess I could use php session variables but it would be nice to be able to manipulate url parameters. Thanks for your input, greatly appreciated. Title: Re: datagrid calls form: how to pass id paramater Post by: andyj on July 31, 2013, 01:45:42 AM Got it now.
It should be: Code: $('#fm1').form('load','data_select.php?entity_id='+'<?php echo $_GET['entity_id'];?>'); Thanks for putting me on the right track. |