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!

Any thoughts on the best way to accomplish this?

Thanks!

Matt Sones, Champion

- 31,478 Points

Posted 3 years ago

Moshe Karmel, Champion

- 8,646 Points

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

}

if(row.Condition_Field__c == whateverVal){

highlightRow

}

Matt Sones, Champion

- 31,478 Points

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?)

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?)

Moshe Karmel, Champion

- 8,646 Points

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.

PROS: This just may work

CONS: If you have more than a couple of rows, it will take forever for the page to load...

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...

Moshe Karmel, Champion

- 8,646 Points

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.

PROS: This should work awesomely

CONS: None that I can think of

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

(Edited)

Rob Hatch, Official Rep

- 44,006 Points

Matt Sones, Champion

- 31,478 Points

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.

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');

}

(Edited)