Method Community

 

Changing the cell colour for certain rows in a grid

Last post 07-17-2015 3:53 PM by Method_Morty. 5 replies.
Page 1 of 1 (6 items)
Sort Posts: Previous Next
  • 07-16-2015 3:15 PM

    Changing the cell colour for certain rows in a grid

    Let's say I have a grid that is a customer order form (using the Method Customer Portal)

    When someone selects a quantity of a certain item to order, I already have a series of actions linked to "Lose Focus" that adds that number of items to a grid. However, let's say I wanted to add actions where if the quantity typed in exceeds the amount of items in inventory, the "Name" field for that row becomes a highlighted red cell.

    In addition, let's say on screen load, I want to highlight in red all Name cells in rows where the inventory for that item is 0 (or less).

    I have been playing around with the "Set Color For Field/Object" in a grid on a test screen that I have. I have a column that is a link (labelled "Select") that currently sets the active Record ID for the screen. As a test, I added the "Set Color For Field/Object" action and selected the "Customer:FullName" field that also represents a grid column. I use the "Type In" option and enter a hex colour code for red (#fd0303). But nothing happens after I Save the screen and press the "Select" link in any row of the grid.

    Do I need to loop through the grid first? Something else?

  • 07-17-2015 10:12 AM In reply to

    Re: Changing the cell colour for certain rows in a grid

    Hey Mike,

    You cannot change the color of the Name field for the Row on Grid using the 'Set Color For Field/Object' Action.  

    What you can do is use an Override SQL query. You don't need to use any Actions. You will go into Advanced options for the field Name on Grid add the query. For your example: 

    (CASE WHEN QuantityOnHand < 0 THEN '<font color=''red''>' + Name + '</font>' ELSE Name END)

    In other words, if QOH is less than 0 then change the color of the Name to Red.

    Give that a try and let me know how it works out.

    - Mortaza

    Morty Barighzaai
    Customer Success Manager
    Method:CRM
  • 07-17-2015 12:19 PM In reply to

    Re: Changing the cell colour for certain rows in a grid

    Thank you. I am an SQL novice but I can usually work around existing coding or examples like you provided.

    What about on the order form? Would I use the same type of coding that you provided as an example?

    So...if someone orders 5 items and we only have 3, use the same SQL in a conditional loop?

  • 07-17-2015 2:32 PM In reply to

    Re: Changing the cell colour for certain rows in a grid

    Hey Mike,

    The Order Form is that just on screen field/objects?

    If it's field/objects on screen (e.g. text input fields) then you can use the 'Set Color For Field/Object' Action. The SQL should be only for changing colors in the Grid.

    First you'll need to retrieve the QOH for the Item your Customer chose. That will require a Retrieve Value from Table Action save that as a Action Result we can use later.

    Then the condition should check if you have enough QOH for the quantity the Customer chose. IF NOT then 'Set Color For Field/Object' for the field.

    Let me know if you need to me to elaborate on any of the steps.

    - Mortaza

    Morty Barighzaai
    Customer Success Manager
    Method:CRM
  • 07-17-2015 3:12 PM In reply to

    Re: Changing the cell colour for certain rows in a grid

    Not really - it's a series of grids.

    I was wondering if you could highlight a cell in a particular row (eg. the Name field for a particular item ordered) where the Quantity selected exceeds current inventory.

    It's not a critical thing, and I have tested what you suggested above - changing colours for buttons on the screen. That works. I just didn't know if it could work within a grid and if so, would a loop need to be done.

  • 07-17-2015 3:53 PM In reply to

    Re: Changing the cell colour for certain rows in a grid

    Hey Mike,

    That won't be possible because we can't set Events to the Grid. Let's say the User tabs into the next column, there is no way for us to catch if he did that within the Grid.

    If you wanted to use fields to capture the Users inputs (Item Name) we can capture the event on a Lose Focus but then we can't call the SQL since it's hardcoded in the Grid per Field, a Loop Through Grid would not work in this case.

    SQL Override will always execute OnScreenLoad. You can set an Action to a Button that can refresh the Grid which will re-execute the SQL query and accept any changes that were done, but that can only happen after a Save has been completed and the Tables reflect that change.

    If you want to add a screenshot of what your screen currently looks like I can try to put together an alternative route we can take.

    - Mortaza

    Morty Barighzaai
    Customer Success Manager
    Method:CRM
Page 1 of 1 (6 items)