Highlighting Specific Records

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.
Tekno Venus
AppGini Super Hero
AppGini Super Hero
Posts: 56
Joined: 2013-01-10 16:37
Location: England
Contact:

Highlighting Specific Records

Post by Tekno Venus » 2013-02-20 18:48

I'm not sure if this is possible, but I would like to give it a try :)

In my database I have a drop down list with a couple of different options in. My goal here is to automatically highlight all the rows in the table with one option from the list selected.

For example, if the drop down list had 2 values, yes and no, I would like any data that has a Yes value to have a red font colour which can be done in HTML.

The only way I can think of doing is via Javascript, but I'm not sure. I think the best way to do this here would be to customize the tablename_footer or tablename_footer hook for the table and to insert some javascript code for colourizing the specific records. I can do the JS (something like document.getElementById('').style.color="red";), but I'm not sure how I could check for a specific value, ie. yes or no.

Does anyone have any ideas on how to do this?

Thanks,
Stephen
Stephen Foulds

Admin, Sysnative Forums -- Sysnative Forums

pgkounelas
Posts: 10
Joined: 2013-01-30 14:55
Location: Larissa, Hellas

Re: Highlighting Specific Records

Post by pgkounelas » 2013-02-21 10:23

Stephen, This is the code you need, from appginni tutorials.

Code: Select all

function tablename_init(&$options, $memberInfo, &$args){	
	// modify the status field of the table view query to display 'no' invoices in bold red
		$oldArray=$options->QueryFieldsTV;
		$options->QueryFieldsTV='';
		foreach($oldArray as $field => $caption){
			if($field=='`tablename`.`fieldname`'){
				$options->QueryFieldsTV['IF(`tablename`.`fieldname`=\'yes\', \'<b style="color: green;">YES</b>\', IF(`tablename`.`fieldname`=\'no\', \'<b style="color: red;">NO</b>\', `tablename`.`fieldname`))']=$caption;
			}else{
				$options->QueryFieldsTV[$field]=$caption;
			}
		}
			return TRUE;
	}

Tekno Venus
AppGini Super Hero
AppGini Super Hero
Posts: 56
Joined: 2013-01-10 16:37
Location: England
Contact:

Re: Highlighting Specific Records

Post by Tekno Venus » 2013-02-21 18:30

Thanks, I will try that when I get a chance!

Where did you find this? Or did you make this yourself?

Stephen
Stephen Foulds

Admin, Sysnative Forums -- Sysnative Forums

pgkounelas
Posts: 10
Joined: 2013-01-30 14:55
Location: Larissa, Hellas

Re: Highlighting Specific Records

Post by pgkounelas » 2013-02-21 18:44

This piece of code I found here:
http://bigprof.com/appgini/free-open-so ... plications
the page is "Download free open source web applications" click on the link "Download Simple Invoicing".
and in the hooks folder the file invoices.php have all the code.

Tekno Venus
AppGini Super Hero
AppGini Super Hero
Posts: 56
Joined: 2013-01-10 16:37
Location: England
Contact:

Re: Highlighting Specific Records

Post by Tekno Venus » 2013-02-21 19:35

Ahhh, thank you very much.

I am currently working on other stuff, but will try this ASAP. Thanks for the code! :)
Stephen Foulds

Admin, Sysnative Forums -- Sysnative Forums

Tekno Venus
AppGini Super Hero
AppGini Super Hero
Posts: 56
Joined: 2013-01-10 16:37
Location: England
Contact:

Re: Highlighting Specific Records

Post by Tekno Venus » 2013-02-22 20:26

This works great! Thank you very much!!
Stephen Foulds

Admin, Sysnative Forums -- Sysnative Forums

Tekno Venus
AppGini Super Hero
AppGini Super Hero
Posts: 56
Joined: 2013-01-10 16:37
Location: England
Contact:

Re: Highlighting Specific Records

Post by Tekno Venus » 2013-02-23 21:02

Ok, I am now having an issue and require help.

The original code:

Code: Select all

function tablename_init(&$options, $memberInfo, &$args){   
   // modify the status field of the table view query to display 'no' invoices in bold red
      $oldArray=$options->QueryFieldsTV;
      $options->QueryFieldsTV='';
      foreach($oldArray as $field => $caption){
         if($field=='`tablename`.`fieldname`'){
            $options->QueryFieldsTV['IF(`tablename`.`fieldname`=\'yes\', \'<b style="color: green;">YES</b>\', IF(`tablename`.`fieldname`=\'no\', \'<b style="color: red;">NO</b>\', `tablename`.`fieldname`))']=$caption;
         }else{
            $options->QueryFieldsTV[$field]=$caption;
         }
      }
         return TRUE;
This code works fine to replace the field text with a specific string, for example <b>Yes</b>. Where the field has the value of Yes, it will be replaced with <b>Yes</b>

Now, what I want to do is wrap the <b></b> tags around EXISTING data. To explain, the table already has data in. What I want it to do is when one field says yes, make the data already in the other field bold.

I am close to this with this code:

Code: Select all

// modify the status field of the table view query to display 'Windows Update' drivers in bold red
      $oldArray=$options->QueryFieldsTV;

	  
      $options->QueryFieldsTV='';
      foreach($oldArray as $field => $caption){
         if($field=='`SaD`.`info`'){
            $options->QueryFieldsTV['IF(`SaD`.`source`="Windows Update", "<b>Yes</b>",  `SaD`.`info` )']=$caption;
         }
		 else{
            $options->QueryFieldsTV[$field]=$caption;
         }
      }
This code checks to see if the data in SaD.source says Windows Update. If it does it replaces the data in SaD.info with Yes. However, what I want to do is wrap the existing data in the SaD.info field with <b> tags so it makes that data bold.

I tried this but it does not work:

Code: Select all

// modify the status field of the table view query to display 'Windows Update' drivers in bold red
      $oldArray=$options->QueryFieldsTV;

	  
      $options->QueryFieldsTV='';
      foreach($oldArray as $field => $caption){
         if($field=='`SaD`.`info`'){
            $options->QueryFieldsTV['IF(`SaD`.`source`="Windows Update", "<b style=color:red>"SaD.info"</b>",  `SaD`.`info` )']=$caption;
         }
		 else{
            $options->QueryFieldsTV[$field]=$caption;
         }
      }
To give a worked example, if SaD.source said "Windows Update" and SaD.info said "Windows OS Kernel Driver", I want to make the "Windows OS Kernel Driver" bold.

Does this make sense? Can anyone help? I have been trying for ages to get this to work!!!

Thanks to anyone who can help
Stephen
Stephen Foulds

Admin, Sysnative Forums -- Sysnative Forums

User avatar
a.gneady
Site Admin
Posts: 1281
Joined: 2012-09-27 14:46
Contact:

Re: Highlighting Specific Records

Post by a.gneady » 2013-02-25 08:28

Try this as the second parameter to the IF function in your code:

Code: Select all

CONCAT("<b style=color:red>", `SaD`.`info`, "</b>")
:idea: AppGini plugins to add more power to your apps:
  • DataTalk is an innovative AppGini plugin based on ChatGPT that allows you to interact with your AppGini database using natural language questions, without writing any SQL. Check the demo video
  • Mass Update plugin: Update multiple records at once and improve your workflow efficiency.
  • Check our other plugins and get a generous discount of up to 30% when buying 2 or more plugins.

Tekno Venus
AppGini Super Hero
AppGini Super Hero
Posts: 56
Joined: 2013-01-10 16:37
Location: England
Contact:

Re: Highlighting Specific Records

Post by Tekno Venus » 2013-02-25 18:49

THANK YOU AHMAD!!!

That worked perfectly! Issue solved and thanks again!

Stephen
Stephen Foulds

Admin, Sysnative Forums -- Sysnative Forums

selectsteel
Posts: 26
Joined: 2013-09-23 14:14

Re: Highlighting Specific Records

Post by selectsteel » 2013-09-25 18:41

I to have been trying to get somthing like this to work for some time. I want to change the color of the text in a column if it has a value in it and I would actually like to change the color of the cell if possible.
I have tried a hundred variations on the code below with no success.

Code: Select all

  options->QueryFieldsTV['IF(`tablename`.`column` != "" ,  CONCAT('<font color="red">' , `tablename`.`column` , '</font>'))']=$caption;
any help would be appreciated.

User avatar
a.gneady
Site Admin
Posts: 1281
Joined: 2012-09-27 14:46
Contact:

Re: Highlighting Specific Records

Post by a.gneady » 2013-10-12 14:45

You need to escape the single quotes inside the index as follows:

Code: Select all

options->QueryFieldsTV['IF(`tablename`.`column` != "" ,  CONCAT(\'<font color="red">\' , `tablename`.`column` , \'</font>\'))']=$caption;
:idea: AppGini plugins to add more power to your apps:
  • DataTalk is an innovative AppGini plugin based on ChatGPT that allows you to interact with your AppGini database using natural language questions, without writing any SQL. Check the demo video
  • Mass Update plugin: Update multiple records at once and improve your workflow efficiency.
  • Check our other plugins and get a generous discount of up to 30% when buying 2 or more plugins.

D Campbell
Posts: 20
Joined: 2017-03-12 09:32

Re: Highlighting Specific Records

Post by D Campbell » 2017-08-21 17:37

how do you add more than two records to that? I only got two of records from drop down menu to work?

D Campbell
Posts: 20
Joined: 2017-03-12 09:32

Re: Highlighting Specific Records

Post by D Campbell » 2017-08-21 17:40

also, when one of drop menu list is selected, and i would like to have entire row in color on the background as well.

D Campbell
Posts: 20
Joined: 2017-03-12 09:32

Re: Highlighting Specific Records

Post by D Campbell » 2017-08-21 18:24

Finally got it figured out.... it was just to add one more parenthesis at end of statement and go on when you need more than two records on the same column.

** change "tablename" and "fieldname" to your table name and column name of the table you created. Replace three names (John Doe, Jane Doe and Baby Doe) to whatever you created under the column or list under drop down menu or checklist or whatever. **

example:

$options->QueryFieldsTV['IF(`tablename`.`fieldname`=\'john doe\', \'<b style="color: red;">John Doe</b>\', IF(`tablename`.`fieldname`=\'jane doe\', \'<b style="color: blue;">Jane Doe</b>\', IF(`tablename`.`fieldname`=\'baby doe\', \'<b style="color: green;">Baby Doe</b>\', `tablename`.`fieldname`)))']=$caption;

Ionut Bocanet
Posts: 28
Joined: 2017-03-12 09:26
Contact:

Re: Highlighting Specific Records

Post by Ionut Bocanet » 2019-11-11 11:51

Dear Sirs,

I need a little help. I used the below code to highlight a record based on a Status Value. It is working fine in Details View of the Parent Records, but it is not working at child level.

<script>
$j(function(){
$j('.Agenda_Item_Action_Log-Status').each(function(){
var Status=$j(this).text();
if(Status=='Completed'){
$j(this).parents('tr').addClass('success');

}
if(Status=='In Progress'){
$j(this).parents('tr').addClass('warning');
}

if(Status=='Not Started'){
$j(this).parents('tr').addClass('primary');

}
})

It is possible to help me to have the formatting also on the children records.

In example 1 you can see how it appears in Details View and proves the code working.

In example 2 i want to achieve the same thing.


Thank you in advanced
Attachments
example2.png
This example is how the detail view looks like with the child record.
example2.png (240.68 KiB) Viewed 11083 times
example1.png
Primary Detail view
example1.png (173.66 KiB) Viewed 11083 times
Best Regards,
Ionut Bocanet

pbottcher
AppGini Super Hero
AppGini Super Hero
Posts: 1635
Joined: 2018-04-01 10:12

Re: Highlighting Specific Records

Post by pbottcher » 2019-11-11 18:31

Hi,

where do you have the code you posted?
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.

User avatar
onoehring
AppGini Super Hero
AppGini Super Hero
Posts: 1156
Joined: 2019-05-21 22:42
Location: Germany
Contact:

Re: Highlighting Specific Records

Post by onoehring » 2019-11-12 09:39

Hi Ionut,

the problem might be that the details are rendered by ajax - maybe after the page code has been loaded already.
You may try the jquery ready event and run your markup-js-code once the page is actually ready (ajax done).

Olaf

Ionut Bocanet
Posts: 28
Joined: 2017-03-12 09:26
Contact:

Re: Highlighting Specific Records

Post by Ionut Bocanet » 2019-11-12 12:30

pböttcher wrote:
2019-11-11 18:31
Hi,

where do you have the code you posted?
Hello Sir,

This code i took it from the course supplied by Appgini in the Udemy website.
Best Regards,
Ionut Bocanet

User avatar
onoehring
AppGini Super Hero
AppGini Super Hero
Posts: 1156
Joined: 2019-05-21 22:42
Location: Germany
Contact:

Re: Highlighting Specific Records

Post by onoehring » 2019-11-12 12:46

Hi Ionut,

maybe check out these old posts of mine:
viewtopic.php?f=2&t=3104&p=10371#p10381
viewtopic.php?f=2&t=3194&p=10935#p10935
and
viewtopic.php?f=7&t=3280&p=11325#p11322

I think these might help. In the first link I am adding something to the details, using a setInterval function - not as good as the ready event probably, but it works. I suppose by rewriting the code you will be able to get what you need.

Olaf

federico
Veteran Member
Posts: 74
Joined: 2020-10-29 14:52

Re: Highlighting Specific Records

Post by federico » 2020-11-28 17:00

Ionut Bocanet wrote:
2019-11-11 11:51

<script>
$j(function(){
$j('.Agenda_Item_Action_Log-Status').each(function(){
var Status=$j(this).text();
if(Status=='Completed'){
$j(this).parents('tr').addClass('success');

}
if(Status=='In Progress'){
$j(this).parents('tr').addClass('warning');
}

if(Status=='Not Started'){
$j(this).parents('tr').addClass('primary');

}
})
Hi! Did you fix it? I have the same problem for a children table. I wrote the code in footer-extra.php file
tks

pbottcher
AppGini Super Hero
AppGini Super Hero
Posts: 1635
Joined: 2018-04-01 10:12

Re: Highlighting Specific Records

Post by pbottcher » 2020-11-28 20:51

Hi,

you can see the the code in

viewtopic.php?f=2&t=4025&sid=19c71490cb ... 4d9#p15525

just replace the code in the wait_for call with your code
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.

federico
Veteran Member
Posts: 74
Joined: 2020-10-29 14:52

Re: Highlighting Specific Records

Post by federico » 2020-12-01 15:28

Hi

first of thanks for your answer. I'm sorry but I'm little noob on this. I'm trying the below code where the children table is Agenda and the parent table is Clienti:

<script>
$j(function wait_for(data,callback,time=1000) {
$j('.Clienti-Agenda-Stato').each(function(){
var Stato = $j(this).text();
if(Stato == 'Attesa Azione Cliente'){
$j(this).parents('tr').addClass('warning');
}
if(Stato == 'Attesa Azione Tecnoplastic'){
$j(this).parents('tr').addClass('danger');
}
if(Stato == 'Attesa Azione Commerciale'){
$j(this).parents('tr').addClass('success');
}
})
})
</script>

pbottcher
AppGini Super Hero
AppGini Super Hero
Posts: 1635
Joined: 2018-04-01 10:12

Re: Highlighting Specific Records

Post by pbottcher » 2020-12-01 22:17

hmmm,

try

Code: Select all

<script>
$j(function() {
	function wait_for(data,callback,time=100) {
		if($j(data).length != 0) {
			callback();
			return;
		}
		else {
			setTimeout(function() {
				wait_for(data,callback, time);
			}, time);
		}
	}
	wait_for('.table-striped',function() {
		$j('.Clienti-Agenda-Stato').each(function(){
			var Stato = $j(this).text();
			if(Stato == 'Attesa Azione Cliente'){
				$j(this).parents('tr').addClass('warning');
			}
			if(Stato == 'Attesa Azione Tecnoplastic'){
				$j(this).parents('tr').addClass('danger');
			}
			if(Stato == 'Attesa Azione Commerciale'){
				$j(this).parents('tr').addClass('success');
			}
		})
	})
})
</script>
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.

federico
Veteran Member
Posts: 74
Joined: 2020-10-29 14:52

Re: Highlighting Specific Records

Post by federico » 2020-12-02 08:54

I'm sorry. It doesn't work. I'm copying it on footer-extra file right?
I also try on another database, but nothing happen.
I noticed that if I try to open an attached file on the record of the sub-table, the file is empty, meanwhile if I open the file directly in that table (from the link in homepage) it works. Could depends on the appgini update? Or is this just another problem?

pbottcher
AppGini Super Hero
AppGini Super Hero
Posts: 1635
Joined: 2018-04-01 10:12

Re: Highlighting Specific Records

Post by pbottcher » 2020-12-02 11:13

Hi,

the file openening is another problem, not related to this question.

For this question.
Are you sure you have the correct Class you are looking at? Is "Clienti-Agenda" the child table name and "Stato" the fieldname? Is the Text exactly what the $j(this).text() returns?

Maybe you can post a screenshot of the definitions.

The code itself works. I tested it on my testsystem.
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.

Post Reply