Page 1 of 1

Colors not changed in child records

Posted: 2014-03-11 20:09
by benzoD
I'm trying to implement a color change of a field for certain data using this forum thread. It works great for TV as a parent but in the child view the colors are not changed.

In the tablename_init hook, I have my workorders.status text changing color based on what the data is (if workorder.status = "Complete", font-color="red"). I also have a location table, and related child workorder records are displayed under each location record. When viewing the workorder records as children, the color does not take effect.

Examples-
Working in TV:
Image

Not working as child ("New" should be green):
Image

Here is the code I'm using in hooks/workorders.php:

Code: Select all

function workorders_init(&$options, $memberInfo, &$args){
      $oldArray=$options->QueryFieldsTV;
      $options->QueryFieldsTV='';
      foreach($oldArray as $field => $caption){
         if($field=='`workorders`.`status`'){
            $options->QueryFieldsTV['IF(`workorders`.`status`=\'New\', \'<b style="color: green;">New</b>\', IF(`workorders`.`status`=\'Complete\', \'<b style="color: red;">Complete!</b>\', `workorders`.`status`))']=$caption;
         }
      else
         {
            $options->QueryFieldsTV[$field]=$caption;
         }
      }
Where else must I place the code to color the records the same across all views?

Re: Colors not changed in child records

Posted: 2014-03-12 19:11
by benzoD
Additionally, if the child records are controlled by a different set of files or code (and it appears that they are), how can I control the buttons that are rendered for the child records? I'd like to disable the Add New button on certain pages and child records but not all.

Re: Colors not changed in child records

Posted: 2014-03-27 15:27
by benzoD
I figured out the second question. I just had to find its unique selector for CSS then add "display: none;" to the bottom of the CSS file.

So, I hid the Add New button on my pages with this bit of CSS:

Code: Select all

button#addNew.btn.btn-success {
     display:none;
}
This hides all the Add New buttons on the detail pages, but not the Add New buttons on the child record tabs that are shown below the table view.

I also disabled the Add New button on a specific child record by using

Code: Select all

#panel_childTableName-parentTableName a{
     display: none;
}
This hides the Add New and Refresh buttons in the child panel below the parent Detail view. I only needed to display data in this particular panel.

My app flow may be a little different than most but hopefully this will help someone.