Double click to view a record

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.
Post Reply
justsimple
User
Posts: 17

Double click to view a record

Post by justsimple »

I would like to open view of the record when double click on list rows.
I think I should create java script in Client Scripts -> Table-Specific -> List Page -> Startup Script but I'm not knowledgeable yet to link the id record and appreciated if someone can help.


mobhar
User
Posts: 11703

Post by mobhar »

Assume you are using "trademarks" table from the demo project, then simply put the following code in "Startup Script" that belongs to the List Page:

$(document).ready(function() {
$('tr').dblclick(function(){
var row_id = $(this).attr('id');
var id = $("#" + row_id + " input[name='key_m[]']").val();
window.location = "trademarksview.php?showdetail=&ID="+id;
});
});


justsimple
User
Posts: 17

Post by justsimple »

Thank you so much, it works perfectly.
One thing I noticed though that Modal dialog doesn't function anymore and I tried to change windows.location to that pop up window's URL but nothing to be seen and so is there a way to find out ?


mobhar
User
Posts: 11703

Post by mobhar »

Simply change this code:
window.location = "trademarksview.php?showdetail=&ID="+id;

to:
ew_ModalDialogShow({lnk:this,url:'trademarksview.php?showdetail=&ID='+id,caption:'View'});


Webmaster
User
Posts: 9427

Post by Webmaster »

Better use: (v2017)

$(function() {
$(".ewTableRow, .ewTableAltRow").dblclick(function(){
$(this).find(".ewRowLink.ewView").click();
});
});


mobhar
User
Posts: 11703

Post by mobhar »

Thank you, that is much better, indeed. :-)


andyrav
User
Posts: 641

Post by andyrav »

Hi
Where would you add this code? to startup script for the view?
if so like this

$(document).ready(function() {
$(function() {
$(".ewTableRow, .ewTableAltRow").dblclick(function(){
$(this).find(".ewRowLink.ewView").click();
});
});
});

as can not get this to work.
cheers


mobhar
User
Posts: 11703

Post by mobhar »

  1. mobhar wrote:

simply put the following code in "Startup Script" that belongs to the List Page

  1. Just copy and paste the original code from Webmaster. No need to enclose it with "$(document).ready..." code.

andyrav
User
Posts: 641

Post by andyrav »

tried that but didnt work.

// Write your table-specific startup script here
// document.write("page loaded");
$(function() {
$(".ewTableRow, .ewTableAltRow").dblclick(function(){
$(this).find(".ewRowLink.ewView").click();
});
});
</script>

any ideas?


mobhar
User
Posts: 11703

Post by mobhar »

It should work. Make sure you do not include that closing "</script>" tag. That tag should be added while generating the script files by PHPMaker, and not added manually.

Press [F12] in your browser, and see whether any Javascript error message from "Console" tab -> "All" sub-tab.


napiedra
User
Posts: 142

Post by napiedra »

I am trying to do the following:

Double click on a record to view the Master Detail view using the following:

$(document).ready(function() {
$('tr').dblclick(function(){
var row_id = $(this).attr('id');
var id = $("#" + row_id + " input[name='key_m[]']").val();
window.location = "AA_RiskDetaillist.php?showmaster=AA_Risk&fk_Risk_Id="+id;
});
});

But the id at the end equals unspecified. So I only see the detail table and not the master.

I put the code in the master table client scripts. When I double click I want to see the master record with the detail list table. Just like when I enable "master/detail view" or "master/detail add"

I am using PHPMaker v2017.


mobhar
User
Posts: 11703

Post by mobhar »

Try this:

$(function() {
$(".ewTableRow, .ewTableAltRow").dblclick(function(){
window.open($(this).find(".ewRowLink.ewDetailView").attr('href'), '_self');
});
});

  1. Make sure you have already put it in "Startup Script" of "List Page" that belongs to the master table,
  2. Make sure you have already enabled "Master/Detail View (as Detail)" option from "Table" setup -> "Table Options" -> "List Page" that belongs to the detail table,
  3. Make sure you have already regenerated ALL the script files,
  4. It should work, as I've just tried it here.

shahparzsoft
User
Posts: 361

Post by shahparzsoft »

is there any trick to edit any column by double click without open new page


mobhar
User
Posts: 11703

Post by mobhar »

@shahparzsoft,

The closest approach is by using "Inline Edit"; see the "suppliers" table from the demo project for your reference.


napiedra
User
Posts: 142

Post by napiedra »

mobhar wrote:
Try this:

$(function() {
$(".ewTableRow, .ewTableAltRow").dblclick(function(){
window.open($(this).find(".ewRowLink.ewDetailView").attr('href'), '_self');
});
});

  1. Make sure you have already put it in "Startup Script" of "List
    Page" that belongs to the master table,
  2. Make sure you have already enabled "Master/Detail View (as Detail)"
    option from "Table" setup -> "Table Options" -> "List
    Page" that belongs to the detail table,
  3. Make sure you have already regenerated ALL the script files,
  4. It should work, as I've just tried it here.

This actually works, my problem is that I had the "Master/Detail View (as Detail)" disable. Now the problem I have is that my when I try adding details on this screen, the auto-values are not loading. This is not a big deal if I can change the screen.

Now when I double-click on the master list record is taking me to the: AA_Riskview.php?showdetail=AA_RiskDetail&Risk_Id=14
Instead if after the double-click the link would take me to: AA_RiskDetaillist.php?showmaster=AA_Risk&fk_Risk_Id=14. My problem will be resolved. Becase on this screen everything works as expected.

Can this be done by modifying the script?


mobhar
User
Posts: 11703

Post by mobhar »

  1. Make sure you have already enabled "Selected records" from "PHP" -> "Page Options (Global)" -> "Export", as this will add the checkbox at each row in the List Page (needed for run the following code at step #2 below),

  2. Put the following code in "Startup Script" section that belongs to the List Page of your "AA_Risk" table:

$(document).ready(function() {
$('tr').dblclick(function(){
var row_id = $(this).attr('id');
var id = $("#" + row_id + " input[name='key_m[]']").val();
window.location = "AA_RiskDetaillist.php?showmaster=AA_Risk&fk_Risk_Id"+id;
});
});

  1. Regenerate ALL the script files again.

napiedra
User
Posts: 142

Post by napiedra »

Perfect and Perfect...! Thank you sooo much guys for your hard work!


Post Reply