Highlight rows of a table that meet a certain inactive model condition?

Matt SonesMatt Sones πŸ’ŽπŸ’ŽπŸ’Ž
edited February 10, 2017 in Questions
I have a toggle filter on a table. When the filter is off so that all rows are shown, I'd like the rows that meet the criteria for the condition behind the filter to be highlighted or bold.

Any thoughts on the best way to accomplish this?

Thanks!

Comments

  • edited July 29, 2015
    Use a field renderer snippet to check the model condition manually on every row. There are a bunch of examples on the community of how this can be done. Basically:

    if(row.Condition_Field__c == whateverVal){
    Β  Β  highlightRow
    }


  • Matt SonesMatt Sones πŸ’ŽπŸ’ŽπŸ’Ž
    edited February 10, 2017
    Right.

    Trouble is the condition I want to evaluate is the following subquery condition. Do I have to perform the subquery in javascript every time, or is there a better way (access the 'value' of the condition through the model somehow?)

    image
  • edited July 29, 2015
    OK a little more tricky... I don't know the right way to do this. If you want to get crazy... :

    1) Create a model on the Signature__c object, and recreate the subquery criteria as conditions on this model, set this model to NOT load data on page load, and LIMIT 1, call it "Signature".
    2) Have an additional condition where Interaction__c = "Empty_Value" filterable default off, name this condition "Interaction".Β 
    3) In your snippet, get the Id value of the current Interaction row. Then set this as the value for the "Interaction" condition.

    e.g.
    var signature = skuid.model.getModel('Signature');
    var Id = field.row.Id;
    var interaction = signature.getConditionByName('Interaction');
    signature.setCondition(interaction, Id);
    signature.updateData(function(){
    Β  Β  if(skuid.model.getModel('Signature').data.length){
    Β  Β  Β  Β  highlightRow();
    Β  Β  }
    });
    PROS: This just may work
    CONS: If you have more than a couple of rows, it will take forever for the page to load...

  • edited July 29, 2015
    Actually my previous post is really dumb. Try this:

    1) Clone your Interaction model and call it "InteractionSubquery".
    2) Change the subquery to always be on.
    3) In your snippet, check if the current rows Id exists in the model that has the subquery on, that will indicate that it matches the criteria :

    e.g.
    var interactionSubquery= skuid.model.getModel('InteractionSubquery');
    var Id = field.row.Id;
    if(interactionSubquery.getRowById(Id) != null){
    Β  Β  highlightRow();
    }
    PROS: This should work awesomely
    CONS: None that I can think of
  • Matt SonesMatt Sones πŸ’ŽπŸ’ŽπŸ’Ž
    edited February 10, 2017
    Brilliant!
  • Rob HatchRob Hatch πŸ’ŽπŸ’ŽπŸ’Ž
    edited September 1, 2016
    PROS: Β Moshe Karmel being awsome..
    CONS: Β None that I can thing of!Β 


  • Matt SonesMatt Sones πŸ’ŽπŸ’ŽπŸ’Ž
    edited February 10, 2017
    I've implemented this and it's working perfectly. Thanks for being awesome, Moshe.

    For posterity, here's the code I'm using for a field renderer. I made it generic enough to use it on tables with different models. To use it, you just need to clone your models such that if your table's model is MyModel, your clone is MyModelBold.
    var field = arguments[0],
    value = arguments[1],
    $ = skuid.$;
    skuid.ui.fieldRenderers[field.metadata.displaytype][field.mode](field,value);
    var subqueryModel= skuid.$M(field.model.id + 'Bold');
    var Id = field.row.Id;
    if(subqueryModel.getRowById(Id)){
    Β  Β  field.item.element.addClass('bold-row-text');
    }
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!