Redirect to master data after insert in detail table
Redirect to master data after insert in detail table
Hi, I have this 2 tables with parent/children enabled:
compras (parent)
detalles_compras (children).
Now I need to do this:
When insert a new register into detalles_compras, redirect to compras selected id,and no need to click in "back" button to go to compras details form.
The same thing when update and delete a register from detalles_compras.
Any idea? Thanks a lot.
compras (parent)
detalles_compras (children).
Now I need to do this:
When insert a new register into detalles_compras, redirect to compras selected id,and no need to click in "back" button to go to compras details form.
The same thing when update and delete a register from detalles_compras.
Any idea? Thanks a lot.
Re: Redirect to master data after insert in detail table
Try this.
Create file 'detalles_compras-dv.js' in 'hooks' folder:
Create file 'detalles_compras-dv.js' in 'hooks' folder:
Code: Select all
document.observe('dom:loaded', function() {
var btn = $("insert") || $("update");
if (btn) {
btn.onclick = function() {
var result = detalles_compras_validateData();
if (result == true) {
window.parent.jQuery(".modal").modal("hide");
}
return result;
};
}
btn = $("delete");
if (btn) {
btn.onclick = function() {
var result = confirm("Are you sure you want to delete this record?");
if (result) {
window.parent.jQuery(".modal").modal("hide");
}
return result;
};
}
});
Re: Redirect to master data after insert in detail table
Thank you!! I'll check if it woks.
Re: Redirect to master data after insert in detail table
Hi, thanks @lucid I'v tested the code, but don't works. Any idea?
Re: Redirect to master data after insert in detail table
The code only works for the button delete, do you have any idea why?
Re: Redirect to master data after insert in detail table
Hi,
The code that I gave you simply uses JavaScript functions that are normally called on the page generated by AppGini whenever user clicks, for example, "Save Changes" button. I figured out that details page calls tablename_validateData() function. If validation passes, then it should be safe to return back to the master form (i.e. simulate back button press).
You have to match the name of JavaScript function (i.e. table name). The key line in the code is:
If you use, for example, Chrome browser, try to inspect the Save Changes button an see the exact button ID and name of the function that is invoked on the details form.
In one of my projects, the "Save Changes" button looks like this:
"Back" button looks like this
Note:
The code that I gave you simply uses JavaScript functions that are normally called on the page generated by AppGini whenever user clicks, for example, "Save Changes" button. I figured out that details page calls tablename_validateData() function. If validation passes, then it should be safe to return back to the master form (i.e. simulate back button press).
You have to match the name of JavaScript function (i.e. table name). The key line in the code is:
Code: Select all
var result = detalles_compras_validateData();
In one of my projects, the "Save Changes" button looks like this:
Code: Select all
<button type="submit" class="btn btn-success btn-lg" id="update" name="update_x" value="1" onclick="return contacts_validateData();"><i class="glyphicon glyphicon-ok"></i> Save Changes</button>
Code: Select all
<button type="submit" class="btn btn-default" id="deselect" name="deselect_x" value="1" onclick="window.parent.jQuery('.modal').modal('hide'); return false;"><i class="glyphicon glyphicon-chevron-left"></i> Back</button>
- ID of the "Save Changes" button is update
- Function for the "Save Changes" button is onclick="return contacts_validateData();
- Function for the "Back" button is onclick="window.parent.jQuery('.modal').modal('hide');
Re: Redirect to master data after insert in detail table
Thanks a lot!! it works. I just checked the fields and table names. Now, how can I do to refresh the master form (compras) to load the new values from detalles_compras? there is a function to execute after update/insert or delete in detalles_compras?
Thanks @lucid
Thanks @lucid
Re: Redirect to master data after insert in detail table
Hm, separate refresh of the master form should not be necessary. The code should take care of it automatically. This is what the "Back" button does. All works well in my project.
Code: Select all
window.parent.jQuery(".modal").modal("hide");
Re: Redirect to master data after insert in detail table
Hi @Lucid. I would like to know if you can tell me how to print in a javascript message window the values of some variables of the table detalles_compras when insert some value or delete a record? it's that possible?
Thanks
Thanks
Re: Redirect to master data after insert in detail table
Hi,
I'm sorry for answering your question this late. After some consideration, I decided not to use AppGini any more because it is not suitable for the type of applications that I make.
Good luck!
I'm sorry for answering your question this late. After some consideration, I decided not to use AppGini any more because it is not suitable for the type of applications that I make.
Good luck!
Re: Redirect to master data after insert in detail table
Thanks for all. What tool do you recommend to use?
Re: Redirect to master data after insert in detail table
I will concentrate on Laravel.