How to open DV in modal from TV

The recommended method of customizing your AppGini-generated application is through hooks. But sometimes you might need to add functionality not accessible through hooks. You can discuss this here.
Post Reply
User avatar
ronwill
Veteran Member
Posts: 228
Joined: 2015-08-08 10:12
Location: Cheltenham UK +Weatherford USA

How to open DV in modal from TV

Post by ronwill » 2020-10-19 14:18

Hi,

I would like to be able to select a record in Table view that will open the Detailed view in a modal (not separate page).

It should work similar to like when you click on <%%PLINK(name)%%><%%ADDNEW(name)%%> in a detail view whereby the record opens an editable (if permitted) pop up modal showing just the form contents (No header, menu, footer).

But in this case it should work by selecting the record "td" in table view to open the corresponding DV record in a modal.

Any help appreciated please.

Ron
Ron - Gloucestershire, UK: AppGini Pro V 23.15 Rev 1484 - LOVING IT!
Plugins: Mass Update + Search Page Maker + Summary Reports + Calendar + Messages
Bizzworxx: AppGiniHelper + Inline Detail View
Alejandro Landini: To-Do List + MPI + TV Field Editor
Other: Udemy Course

User avatar
ronwill
Veteran Member
Posts: 228
Joined: 2015-08-08 10:12
Location: Cheltenham UK +Weatherford USA

Re: How to open DV in modal from TV

Post by ronwill » 2020-10-30 16:34

Anyone?
Ron - Gloucestershire, UK: AppGini Pro V 23.15 Rev 1484 - LOVING IT!
Plugins: Mass Update + Search Page Maker + Summary Reports + Calendar + Messages
Bizzworxx: AppGiniHelper + Inline Detail View
Alejandro Landini: To-Do List + MPI + TV Field Editor
Other: Udemy Course

User avatar
jsetzer
AppGini Super Hero
AppGini Super Hero
Posts: 1807
Joined: 2018-07-06 06:03
Location: Kiel, Germany
Contact:

Re: How to open DV in modal from TV

Post by jsetzer » 2020-10-30 16:40

Maybe you should have a look at modal_window function. There is a URL parameter in options. The url should be something like TABLENAME_view.php?SelectedID=1234567. I think you will also need the Embedded=1 parameter. But actually I did not test and don't know for sure, if this idea works for your requirement.
Kind regards,
<js />

My AppGini Blog:
https://appgini.bizzworxx.de/blog

You can help us helping you:
Please always put code fragments inside [code]...[/code] blocks for better readability

AppGini 24.10 Revision 1579 + all AppGini Helper tools

User avatar
jsetzer
AppGini Super Hero
AppGini Super Hero
Posts: 1807
Joined: 2018-07-06 06:03
Location: Kiel, Germany
Contact:

Re: How to open DV in modal from TV

Post by jsetzer » 2020-10-30 17:10

Addendum:
I have tested it, and with the following script you can open a modal page with a detail view in it.

Code: Select all

let options = {
  url: AppGini.currentTableName() + "_view.php?SelectedID=" + id + "&Embedded=1",
  size: 'full',
  footer: [ { label: "Close" } ]
};
modal_window(options);
chrome_TdDWnhpop8.png
chrome_TdDWnhpop8.png (21.48 KiB) Viewed 5263 times

Attention

There are still some challenges with the margins and the proper handling of errors and redirections. I'm afraid that a 100% clean and "hooks-only" solution might not exist at all or/and would cause a lot of additional work.
Kind regards,
<js />

My AppGini Blog:
https://appgini.bizzworxx.de/blog

You can help us helping you:
Please always put code fragments inside [code]...[/code] blocks for better readability

AppGini 24.10 Revision 1579 + all AppGini Helper tools

User avatar
ronwill
Veteran Member
Posts: 228
Joined: 2015-08-08 10:12
Location: Cheltenham UK +Weatherford USA

Re: How to open DV in modal from TV

Post by ronwill » 2020-10-30 17:33

Thanks Jan,

I give this a go.....

Ron
Ron - Gloucestershire, UK: AppGini Pro V 23.15 Rev 1484 - LOVING IT!
Plugins: Mass Update + Search Page Maker + Summary Reports + Calendar + Messages
Bizzworxx: AppGiniHelper + Inline Detail View
Alejandro Landini: To-Do List + MPI + TV Field Editor
Other: Udemy Course

User avatar
ronwill
Veteran Member
Posts: 228
Joined: 2015-08-08 10:12
Location: Cheltenham UK +Weatherford USA

Re: How to open DV in modal from TV

Post by ronwill » 2020-11-03 16:38

Hi Jan,

Works as hoped for/required only problem is opens same number of modals as number of records in a table, not just selected ID
Been playing with it but can't find way round it!!

Cheers,
Ron
Ron - Gloucestershire, UK: AppGini Pro V 23.15 Rev 1484 - LOVING IT!
Plugins: Mass Update + Search Page Maker + Summary Reports + Calendar + Messages
Bizzworxx: AppGiniHelper + Inline Detail View
Alejandro Landini: To-Do List + MPI + TV Field Editor
Other: Udemy Course

User avatar
jsetzer
AppGini Super Hero
AppGini Super Hero
Posts: 1807
Joined: 2018-07-06 06:03
Location: Kiel, Germany
Contact:

Re: How to open DV in modal from TV

Post by jsetzer » 2020-11-03 19:27

Hi Ron,
I cannot see your code, so it's hard for me to say what went wrong.

I don't know what you mean by "selected ID", because in TV there may be none selected, one or many.

My code contains the variable "id" and you have to set it before that function call.

Code: Select all

let id = 1; // <-- you have to find out the id (primary key) of the record you want to open
let options = {
  url: AppGini.currentTableName() + "_view.php?SelectedID=" + id + "&Embedded=1",
  size: 'full',
  footer: [ { label: "Close" } ]
};
modal_window(options);
Kind regards,
<js />

My AppGini Blog:
https://appgini.bizzworxx.de/blog

You can help us helping you:
Please always put code fragments inside [code]...[/code] blocks for better readability

AppGini 24.10 Revision 1579 + all AppGini Helper tools

User avatar
ronwill
Veteran Member
Posts: 228
Joined: 2015-08-08 10:12
Location: Cheltenham UK +Weatherford USA

Re: How to open DV in modal from TV

Post by ronwill » 2020-11-03 22:23

Hi Jan,

I've been putting below code in my filename.DV template file:

Code: Select all

<script>	
				let options = {
								url: AppGini.currentTableName() + "_view.php" + "?SelectedID=<%%VALUE(id)%%>" + "&Embedded=1",
								size: 'full',
								footer: [ { label: "Close" } ]
				};
								modal_window(options);
</script>		
It does exactly what I was after, i.e. when i select any record from table list it opens the selected record in a modal. BUT it opens 3 modals (embedded inside each other, all showing the selected record, I have 3 records in my table list.
AG file is set for enable detail view and show detail view as separate page.

I can upload a demo on my server if that helps!!?
Cheers, Ron
Ron - Gloucestershire, UK: AppGini Pro V 23.15 Rev 1484 - LOVING IT!
Plugins: Mass Update + Search Page Maker + Summary Reports + Calendar + Messages
Bizzworxx: AppGiniHelper + Inline Detail View
Alejandro Landini: To-Do List + MPI + TV Field Editor
Other: Udemy Course

User avatar
jsetzer
AppGini Super Hero
AppGini Super Hero
Posts: 1807
Joined: 2018-07-06 06:03
Location: Kiel, Germany
Contact:

Re: How to open DV in modal from TV

Post by jsetzer » 2020-11-04 05:35

Hi,

(1) your question was about opening up a modal DV from within a Table View (TV). So the code for opening up should be placed in TABLENAME-tv.js, not in detail view.

(2) If you put the code without just inside the script file it will be executed on load and not on selection of any record.

You need a button or link which calls a function. That funtion has to find the selected id, build the url and then open up the modal.
Kind regards,
<js />

My AppGini Blog:
https://appgini.bizzworxx.de/blog

You can help us helping you:
Please always put code fragments inside [code]...[/code] blocks for better readability

AppGini 24.10 Revision 1579 + all AppGini Helper tools

User avatar
ronwill
Veteran Member
Posts: 228
Joined: 2015-08-08 10:12
Location: Cheltenham UK +Weatherford USA

Re: How to open DV in modal from TV

Post by ronwill » 2020-11-05 00:09

Hi Jan,

I'm still getting same result (multi modals). the only way I found to prevent it is by following code in table-TV.js

Code: Select all

$j(function(){

//catch the behavior of clicking on any td , prevent it's defulat , the preventDefault dosn't work try to test it and then put your modal of pop up code in the file
$j("td a").click(function(event){

event.preventDefault();


//put your modal or popup behaviour here
let id = 2; // <-- you have to find out the id (primary key) of the record you want to open
modal_window({
	url: AppGini.currentTableName() + "_view.php?SelectedID=" + id + "&Embedded=1",
	close: function(){
		//do things on close of modal;
	},
	size: 'full',
	title: 'My title'
});



})

})	
This works but can't find a way to change line: let id = 2; to find the primary key of the record (i.e. id=1, id=2, etc.)
Cheers, Ron
Ron - Gloucestershire, UK: AppGini Pro V 23.15 Rev 1484 - LOVING IT!
Plugins: Mass Update + Search Page Maker + Summary Reports + Calendar + Messages
Bizzworxx: AppGiniHelper + Inline Detail View
Alejandro Landini: To-Do List + MPI + TV Field Editor
Other: Udemy Course

User avatar
jsetzer
AppGini Super Hero
AppGini Super Hero
Posts: 1807
Joined: 2018-07-06 06:03
Location: Kiel, Germany
Contact:

Re: How to open DV in modal from TV

Post by jsetzer » 2020-11-06 07:29

Inside your click event handler:

Code: Select all

var id = $j(this).closest('tr[data-id]').attr('data-id');
(Not tested)
Kind regards,
<js />

My AppGini Blog:
https://appgini.bizzworxx.de/blog

You can help us helping you:
Please always put code fragments inside [code]...[/code] blocks for better readability

AppGini 24.10 Revision 1579 + all AppGini Helper tools

User avatar
ronwill
Veteran Member
Posts: 228
Joined: 2015-08-08 10:12
Location: Cheltenham UK +Weatherford USA

Re: How to open DV in modal from TV

Post by ronwill » 2020-11-06 13:04

Hi Jan,

PERFECT! Thank you so much for your help and guidance, I'd never have got there by myself.
Your solution works just how I wanted the end result to be like and allows me to move forward with my project - you saved the day, I as many here will continue to be thankful for all the help and assistance you provide through this forum and with: AppGiniHelper + Inline Detail view (Highly recommend these to everyone).

Cheers,
Ron
Ron - Gloucestershire, UK: AppGini Pro V 23.15 Rev 1484 - LOVING IT!
Plugins: Mass Update + Search Page Maker + Summary Reports + Calendar + Messages
Bizzworxx: AppGiniHelper + Inline Detail View
Alejandro Landini: To-Do List + MPI + TV Field Editor
Other: Udemy Course

User avatar
jsetzer
AppGini Super Hero
AppGini Super Hero
Posts: 1807
Joined: 2018-07-06 06:03
Location: Kiel, Germany
Contact:

Re: How to open DV in modal from TV

Post by jsetzer » 2020-11-06 13:34

Thank you, Ron, for the very kind and appreciative words!
Kind regards,
<js />

My AppGini Blog:
https://appgini.bizzworxx.de/blog

You can help us helping you:
Please always put code fragments inside [code]...[/code] blocks for better readability

AppGini 24.10 Revision 1579 + all AppGini Helper tools

User avatar
ronwill
Veteran Member
Posts: 228
Joined: 2015-08-08 10:12
Location: Cheltenham UK +Weatherford USA

Re: How to open DV in modal from TV

Post by ronwill » 2020-11-15 15:32

Hi Jan,

I just upgraded to AG 5.92 and this solution no longer works?
Any idea what/where/why the upgrade stops this from working?

Cheers, Ron
Ron - Gloucestershire, UK: AppGini Pro V 23.15 Rev 1484 - LOVING IT!
Plugins: Mass Update + Search Page Maker + Summary Reports + Calendar + Messages
Bizzworxx: AppGiniHelper + Inline Detail View
Alejandro Landini: To-Do List + MPI + TV Field Editor
Other: Udemy Course

User avatar
jsetzer
AppGini Super Hero
AppGini Super Hero
Posts: 1807
Joined: 2018-07-06 06:03
Location: Kiel, Germany
Contact:

Re: How to open DV in modal from TV

Post by jsetzer » 2020-11-15 16:07

should still work. Can you please tell, which part does not work any longer:
  • click-event on td
  • getting the id
  • opening the modal
  • other?
Are there any warning or errors in console?
Kind regards,
<js />

My AppGini Blog:
https://appgini.bizzworxx.de/blog

You can help us helping you:
Please always put code fragments inside [code]...[/code] blocks for better readability

AppGini 24.10 Revision 1579 + all AppGini Helper tools

User avatar
ronwill
Veteran Member
Posts: 228
Joined: 2015-08-08 10:12
Location: Cheltenham UK +Weatherford USA

Re: How to open DV in modal from TV

Post by ronwill » 2020-11-15 16:16

Hi Jan,

Sorry, I found the problem:

I had my header.php as read only. Once I removed it, saved as updated by latest version, reapplied my small mods, re-saved again, everything worked as should again.

Best regards Ron
Ron - Gloucestershire, UK: AppGini Pro V 23.15 Rev 1484 - LOVING IT!
Plugins: Mass Update + Search Page Maker + Summary Reports + Calendar + Messages
Bizzworxx: AppGiniHelper + Inline Detail View
Alejandro Landini: To-Do List + MPI + TV Field Editor
Other: Udemy Course

User avatar
jsetzer
AppGini Super Hero
AppGini Super Hero
Posts: 1807
Joined: 2018-07-06 06:03
Location: Kiel, Germany
Contact:

Re: How to open DV in modal from TV

Post by jsetzer » 2020-11-15 16:22

Great! I'm glad it still works in latest version.

Best,
Jan
Kind regards,
<js />

My AppGini Blog:
https://appgini.bizzworxx.de/blog

You can help us helping you:
Please always put code fragments inside [code]...[/code] blocks for better readability

AppGini 24.10 Revision 1579 + all AppGini Helper tools

Post Reply