Using DateCompareType in a conditional format rule instead of a validator

Posted by: randy.nichols on 16 May 2019, 6:01 am EST

  • Posted 16 May 2019, 6:01 am EST

    The only example I could find for this was in the context of a validator.

    https://help.grapecity.com/spread/SpreadSheets12/webframe.html#SpreadJS~GC.Spread.Sheets.ConditionalFormatting.DateCompareType.html

    I’ve attempted to use it in a conditional formatting rule by defining a rule, defining the condition and adding the condition to the rule with:

    rule.condition(condition)
    

    It seems to work but I’m running into an issue with the spread sheet’s toJSON call in that a rule created this way doesn’t serialize properly.

    Is there a proper way to create a conditional format rule with DateCompareType that I’ve overlooked in the doc?

  • Posted 16 May 2019, 7:34 pm EST

    Hi,

    We are able to replicate the issue with the serialization and hence we have forwarded the case to the concerned team for further investigation. Internal tracking ID for the case is #272657. We will let you know about any updates regarding the same.

    Thanks for reporting

  • Posted 17 May 2019, 12:06 am EST

    Thank you for responding so quickly.

  • Posted 17 May 2019, 4:59 am EST

    It doesn’t seem to matter what ruleType I apply to the rule if I attach a condition to it with ```

    rule.condition(condition)

    
    I'm interested in creating rules with isEmpty, isNotEmpty, etc but don't see any rules illustrated with those, only validators. Can you point me to examples of creating rules with them?
  • Posted 19 May 2019, 4:12 pm EST

    Dev team is working is on the serialization issue, we will let you know when once the issue is fixed.

    We apologize for the inconvenience due to the lack of examples in the docs. We have forwarded the request to the concerned team to add more examples on the topic. Till then you may refer to the examples for validation. Both validator and ConditionRule uses the same condition instance, so the method for creation of the condition is the same for both validator and condition rule.

    Please refer to the following code snippet which demonstrates how we could isEmpty condition rule:

    var nCondition = new GC.Spread.Sheets.ConditionalFormatting.Condition(GC.Spread.Sheets.ConditionalFormatting.ConditionType.textCondition, {compareType: GC.Spread.Sheets.ConditionalFormatting.TextCompareType.equalsTo, expected: ""});
                var rule = new GC.Spread.Sheets.ConditionalFormatting.NormalConditionRule();
                rule.ruleType(GC.Spread.Sheets.ConditionalFormatting.RuleType.conditionRuleBase);
                rule.condition(nCondition);
                rule.ranges([new GC.Spread.Sheets.Range(0, 0, 10, 3)]);
                
                var style1 = new GC.Spread.Sheets.Style();
                style1.backColor = "red";            
                rule.style(style1);
    
                sheet.conditionalFormats.addRule(rule);
    
Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels