Page 1 of 1

Click on one of rows and show detail view in modal or pop-up window for add/edit

Posted: 2017-08-16 18:14
by D Campbell
Looking for something like click on one of rows from the table and show detail view in modal or pop-up window for add/edit info then save it, return to table?

Re: Click on one of rows and show detail view in modal or pop-up window for add/edit

Posted: 2018-01-08 17:28
by R Tammam
Hello D Campbell,

you can do it by adjusting the behavior of td on clicking on it

first you will insert your code in tablename-tv.js you will create this file in the hooks folder

then you will need some code like that


$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

})

})

The idea that in normal behavior on clicking on any record it submits a form and open a form for editing , we will jsut change it's behviour to be open in modal or pop up

hope it will help you

Regards,
Reham

Re: Click on one of rows and show detail view in modal or pop-up window for add/edit

Posted: 2020-09-07 09:06
by ronwill
Any chance anyone can give an example of the code to use for this?

I would like to open detailed.dv views in a modal when selected from table.tv table. Tried to figure it out but no success yet!

Cheers, Ron

Re: Click on one of rows and show detail view in modal or pop-up window for add/edit

Posted: 2020-09-10 16:24
by ronwill
I have found a work around for the moment (requires changes to template.tv) but still hope someone can provide a quicker code solution!.

For the required popup modal I do not need add/edit functions to the modal template.dv - I just want it to open as modal instead of separate template.dv page for showing information

Cheers, Ron

Re: Click on one of rows and show detail view in modal or pop-up window for add/edit

Posted: 2021-02-05 20:28
by a.gneady
I know this is a very late reply, but better late than never :roll:

Here is a fix that doesn't involve modifying generated files -- you should add the following code to hooks/footer-extras.php if you want to apply it to all tables, or to hooks/tablename-tv.js if you want to apply it only to a specific table:

Code: Select all

<script>
$j(function() {
   $j('td > a').attr('onclick', '').click(function(e) {
      e.preventDefault();
      var link = $j(this).attr('href') + '&Embedded=1'; // add '&dvprint_x=1' to show non-editable DV
      modal_window({
         url: link,
         size: 'full',
         noAnimation: true,
         title: 'Detail view', /* change that to the desired modal window title */
         close: function() {
            if(confirm('Would you like to reload the table to see changes made in the record?')) location.reload();
         }
      });
   })
})</script>
If you're placing the above code in hooks/tablename-tv.js, please remove the <script> and the </script> lines.