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.
Post Reply
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: 1021
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: Learn all the tips and tricks of customizing AppGini apps through our online course.

:arrow: Mass Update plugin: Update multiple records at once and improve your workflow efficiency.

:arrow: Summary Reports plugin: Build powerful reports and charts for your AppGini apps.

:arrow: Search Page Maker: Compose user-friendly yet powerful search pages for your AppGini apps.

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: 12
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: 1021
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: Learn all the tips and tricks of customizing AppGini apps through our online course.

:arrow: Mass Update plugin: Update multiple records at once and improve your workflow efficiency.

:arrow: Summary Reports plugin: Build powerful reports and charts for your AppGini apps.

:arrow: Search Page Maker: Compose user-friendly yet powerful search pages for your AppGini apps.

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;

Post Reply