This topic is locked

Displaying Edit Page In Popup

5/28/2013 10:56:40 AM
PHPRunner General questions
S
Suety29 author

Hi All,
I have a master detail relationship in my application and i'm using tabs to display and add the child information at the same time that the user is adding the master record. The inline add and edit is not an option in my scenario because the user would have to scroll across too much during the data entry process. I therefore added an "Add" button to the tab which allowed the add form to be opened as a modal form. I used the instructions here: http://xlinesoft.com/blog/2013/04/25/displaying-a-page-in-a-popup-window/.
Now, i have already included an edit button in the grid. What i would like is that the use would click the edit button, and this would open the edit page as a modal form. Which means i need to pass the id for the selected row. Can someone help me figure out how to add it to the myscript.js file mentioned in the blog above?
This is the function i included in the myscript.js file for the edit button:



function Edit()

{

params = {

url: 'test_edit.php?editid1='.recordid,

afterClose: function(win) {

win.destroy(true);



},

headerContent: ''

};

displayPopup(params);

}


how do i get the id parameter? and how do i get the url to include this as the parameter?
Also, just a suggestion for future upgrades of the product, it would be nice to have the option of selecting either inline add/edit or popup add/edit when using tabs for master/detail relationships <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=question&id=21038&image=1&table=forumtopics' class='bbc_emoticon' alt=':D' />

Sergey Kornilov admin 5/28/2013

You definitely need to pass record id to this Edit() function.
Details depend on how you implemented a call to this Edit() function in your application. I suggest to check example #6 at http://xlinesoft.com/phprunner/docs/inserting_button.htm. This example applies to both View page and button added right to the grid on the List page.

S
Suety29 author 5/29/2013



You definitely need to pass record id to this Edit() function.
Details depend on how you implemented a call to this Edit() function in your application. I suggest to check example #6 at http://xlinesoft.com/phprunner/docs/inserting_button.htm. This example applies to both View page and button added right to the grid on the List page.


Thanks for the suggestion... I tried the example suggested and i am able to redirect to the correct edit page... however what i really want is to leave the original page open and onclick of the edit button, open the correct edit form as a modal form.
Can you provide any other suggestions on how to do this?

Sergey Kornilov admin 5/29/2013

Not quite sure I understand it. The example you posted displays page in popup. Are you saying it suddenly started redirecting you to the Edit page instead of opening it in popup?

S
Suety29 author 5/29/2013



Not quite sure I understand it. The example you posted displays page in popup. Are you saying it suddenly started redirecting you to the Edit page instead of opening it in popup?


yes.. that's exactly what's happening when i follow example #6 and insert a button through the visual editor and do the following:
On Server Code:



$result["record"] = $button->getCurrentRecord();


On Client After Code:



location.href="test_edit.php?editid1="+result.record["ID"];


I have changed the "On Client After Code" to:



var id = result.record["ID"];


and added the following to the button code in html mode, so it is opening in the modal form now:



onclick='Edit(id);'


However it's not opening the test_edit.php?editid1='+id (e.g. test_edit.php?editid1=1) page. It is opening the test_list.php?a=return page in the modal form.
This is my code for my function in the myscripts.js file in the source folder:



function Edit(id)

{

params = {

url: 'test_edit.php?editid1='+id,

afterClose: function(win) {

win.destroy(true);

},

headerContent: ''

};

displayPopup(params);

}


so basically, what i need to know is how to get the value from the "On Client After Code" and assign it to 'id' in the myscripts.js file? or how do i get the id for the current record in the grid and use it in the myscripts.js file.

Sergey Kornilov admin 5/29/2013

Your ClientAfter code is incorrect for this task. You need to use the code from your first post in order to open the page in popup. The code you use now is in fact will redirect user to the Edit page.

S
Suety29 author 5/29/2013



Your ClientAfter code is incorrect for this task. You need to use the code from your first post in order to open the page in popup. The code you use now is in fact will redirect user to the Edit page.


Thanks for the response... i actually edited the previous post with the changes i had made so it is now opening in modal form but it's not opening the correct page and not reading the id. Can you check my previous post and give me an idea of what i'm doing wrong?

S
stiven 5/31/2013

Are you calling the Edit() function with an onclick event? if so just include the id in the parameters of the function...
There are different ways to get the id depending on the page you are in.


$link = '<a href="#" onclick="Edit(passidhere)"> Open Edit in Pop Up</a>';
function Edit(id)

{

params = {

url: 'test_edit.php?editid1='+id,

afterClose: function(win) {

win.destroy(true);

},

headerContent: ''

};

displayPopup(params);

}


hope this helps