table view customizations

Discussions related to customizing hooks. Hooks are documented at http://bigprof.com/appgini/help/advanced-topics/hooks/
Post Reply
grimblefritz
Veteran Member
Posts: 318
Joined: 2015-12-23 16:52

table view customizations

Post by grimblefritz » 2016-07-15 03:30

I've seen a few questions about this, so after finally digging into it myself -- I thought I'd share.

Basically, the following code hooks/tablename-tv.js tweaks a few column headings and adds a breadcrumb.

One of the major annoyances of AG is that, once you've opened a table, then a detail record, then child records - there's no clean way to get back to the parent detail record.

This hook fixes that.

Code: Select all


// hooks/order_items-tv.js

$j(function(){

  // right align a couple of table headers
  
  $j('th.order_items-quantity').addClass('text-right');
  $j('th.order_items-amount').addClass('text-right');

  // add a back-to-orders link if item table view with a filter set

  var view=$j('#current_view').val();
  var id=$j('input[name="filterer_orders_id"]').val()*1;

  if(view=='TV' && id>0){

    var linktext='<a style="text-decoration: none; color: inherit;" href="orders_view.php?SelectedID='+id+'"><img src="resources/table_icons/cart.png"> Orders </a> ';

    $j('a[href="order_items_view.php"]').before(linktext);

  }

});
When this is implemented, and you drill into order items from an order detail view, then the child (order items) table view will have two icons/titles above it - one that takes you back to the orders record where you came from, and the other will switch you to a global order items view (same as AG has always done.)

Of course, you can tweak the hook. Drop the image. Alter the url. Don't add a new <a> tag, but alter the existing one. Just depends on your skills with jquery. And google :-)


Enjoy!

Bertv
Veteran Member
Posts: 65
Joined: 2013-12-11 15:59

Re: table view customizations

Post by Bertv » 2016-07-15 10:11

grimblefritz,
thank you for sharing this script. It works great.
Bert
I am using Appgini 5.75

DevGiu
AppGini Super Hero
AppGini Super Hero
Posts: 151
Joined: 2016-05-27 09:08

Re: table view customizations

Post by DevGiu » 2016-11-02 12:32

Well, Based on grimblefritz code, I think I improved this a little more.

I have a global js file with this function (change the name as you wish)

Code: Select all

function titulo_vista_referencia_documento(tabladetalle, tablacabecera){
	var view=$j('#current_view').val();
	var cabecera = (tabladetalle == tablacabecera);
	var enlacetitulo = 	(cabecera ? tablacabecera : tabladetalle);

	if (!cabecera)
		var id=$j('input[name="filterer_documento_id"]').val()*1;
	else
		var id=$j('input[name="SelectedID"]').val()*1;

	var referencia = '';

	if (!cabecera) {
		var linktext='<a style="text-decoration: none; color: inherit;" href="' + tablacabecera + '_view.php?SelectedID='+id+'"> <span class="glyphicon glyphicon-arrow-left" aria-hidden="true"></span> Volver </a> ';
		$j('a[href="fac_det_fac_s_view.php"]').before(linktext);
	}	
}
Now, for your details views, you can create their magic file for table_view (<table>-tv.js)
And write this code

Code: Select all

$j(function(){
  titulo_vista_referencia_documento('fac_det_fac_s', 'fac_cab_fac_s');
});
Where:
'fac_det_fac_s' is your detail table
'fac_cab_fac_s' is your parent table.

Now, every detail table you wrote this, you get a "back" button like the screenshot.

Note: Remember to change the text "Volver" to your lang.
Attachments
screenshot_041.png
screenshot_041.png (14.17 KiB) Viewed 3247 times
/Giuseppe
Professional Outsourcing Services

svassell
Posts: 1
Joined: 2019-01-03 15:59

Re: table view customizations

Post by svassell » 2019-01-12 15:27

This is a super useful item for my app. I've attempted to add this to my app with no success. The text is in Spanish which I've tried to translate: Can someone please provide some guidance on the following?
Where do I save the global.js file?
Is the syntax correct?
When adding to the detail and add new pages where does it go?


function get_breadcrumbs(detailed_table, headboard){
var view=$j('#current_view').val();
var headboard = (detailed_table == headboard);
var linktitle = (headboard ? headboard : detailed_table);

if (!headboard)
var id=$j('input[name="filterer_document_id"]').val()*1;
else
var id=$j('input[name="SelectedID"]').val()*1;

var reference = '';

if (!headboard) {
var linktext='<a style="text-decoration: none; color: inherit;" href="' + headboard + '_view.php?SelectedID='+id+'"> <span class="glyphicon glyphicon-arrow-left" aria-hidden="true"></span> Return </a> ';
$j('a[href="hm_property_details.php"]').before(linktext);
}
}


-- Added to the detail page
$j(function()
{
get_breadcrumbs('hm_property_details.php', 'hm_property.php');
});
As always your help is greatly appreciated.

Post Reply