Skip to content

Set Custom Color Indicator in List View - Merci Web Designer

Overview

In Merciglobal Cloud ERP, developers and administrators can enhance the user interface of list views by setting custom color indicators using simple PHP logic. This guide provides a detailed example of how to dynamically set the color of the first column in a list view based on conditions fetched from the database.


Module/Table Setup

Navigate to the Merci Web Designer and select the desired Module/Table where the list customization is required.

Under the Table Script section, choose: - Script Type: List - Color (Web)

Insert the following PHP code:

$cQ  = "SELECT id
        FROM #trn_salesreturn
        WHERE billno={$row['bserial']} AND compid={$row['compid']}";
$resz = myExecute($cQ);
if ($resz->num_rows > 0){
   $firstcoldata .= "CLR:#ff99cc;";
}
$resz->close();

How It Works

  • The $row variable is automatically available during list view rendering and contains the data for each row.
  • The $firstcoldata variable is used to dynamically assign the color code for the first column.
  • The script checks for a matching record in the #trn_salesreturn table using:
  • billno = {$row['bserial']}
  • compid = {$row['compid']}
  • If a match is found, it sets the background color of the first column to pink (#ff99cc).

Performance Tips

⚠️ Important: Make sure that the fields used in the WHERE clause (i.e., billno, compid) are indexed in the #trn_salesreturn table. This ensures faster execution for each row processed in the list view.


Use Cases

  • Highlight records that have related entries in another table.
  • Visually indicate certain statuses, such as returns, payments, or issues.
  • Improve user experience by providing quick visual insights.

Notes

  • This script runs for each row processed during the rendering of the list view.
  • Background color will only be applied if the condition is met — in this case, if a related Sales Return record exists.
  • $firstcoldata must be properly constructed as it directly affects the UI.

Example Scenario

Suppose you're listing invoices in a sales register. To quickly identify which invoices have a corresponding sales return, this color indicator method visually highlights them, aiding quick analysis.


For more development guides and UI enhancements in Merciglobal Cloud ERP, keep following our documentation updates!