Does anyone know how to make a row rule fire when first loading a record? I’m trying to disable a button in RMA Processing when the RMA is open, but it is only evaluating when the row is changed, not when the record is initially loaded.
I can use notify to work around it if I have to, but I would like to use row rules if possible. Does anyone have any special little tricks to make them evaluate on load?
I have one for true and one for false. It works fine when I check the box and change it. But won’t evaluate on record load. ReadOnly = true acts the same way.
private void CreateRowRuleRMAHeadOpenRMAEquals_true()
{
// Description: AddMemoOnlyWhenClosed
// **** begin autogenerated code ****
RuleAction[] ruleActions = new RuleAction[0];
// Create RowRule and add to the EpiDataView.
// Dummy Context Object
object contextObject = null;
RowRule rrCreateRowRuleRMAHeadOpenRMAEquals_true = new RowRule("RMAHead.OpenRMA", RuleCondition.Equals, true, new RowRuleActionDelegate2(this.RMAHeadOpenRMAEqualstrue_CustomRuleAction), contextObject);
((EpiDataView)(this.oTrans.EpiDataViews["RMAHead"])).AddRowRule(rrCreateRowRuleRMAHeadOpenRMAEquals_true);
// **** end autogenerated code ****
}
private void RMAHeadOpenRMAEqualstrue_CustomRuleAction(Ice.Lib.ExtendedProps.RowRuleDelegateArgs args)
{
// ** RowRuleDelegateArgs Properties: args.Arg1, args.Arg2, args.Context, args.Row
// ** put custom Rule Action logic here
memoBtn.ReadOnly = true;
EpiDataView edvRmaDtl = (EpiDataView)(oTrans.EpiDataViews["RMADtl"]);
edvRmaDtl.SetCurrentRowProperty("AddCreditBtn", new ControlSettings() { IsEnabled = false });
}
private void CreateRowRuleRMAHeadOpenRMAEquals_true0()
{
// Description: Testing123
// **** begin autogenerated code ****
RuleAction disabledRMADtl_AssemblySeq = RuleAction.AddControlSettings(this.oTrans, "RMADtl.AddCreditBtn", SettingStyle.ReadOnly);
RuleAction[] ruleActions = new RuleAction[] {
disabledRMADtl_AssemblySeq};
// Create RowRule and add to the EpiDataView.
RowRule rrCreateRowRuleRMAHeadOpenRMAEquals_true0 = new RowRule("RMAHead.OpenRMA", RuleCondition.Equals, true, ruleActions);
((EpiDataView)(this.oTrans.EpiDataViews["RMADtl"])).AddRowRule(rrCreateRowRuleRMAHeadOpenRMAEquals_true0);
// **** end autogenerated code ****
}
You attach the RowRule to the Dtl and then check Head value and you can just assign the disabled by picking the style.
PS: I on purpose picked AssemblySeq for the code to generate and then I manually changed the value to RMADtl.AddCreditBtn which is the binding of my button.
Thanks @hkeric.wci. The only thing that needed to be fixed was that I needed to (like you said) add the action to be attached the RMADtl. So if I changed the code that I had to below. It works fine. Interestingly, if I structure the row rule like your example, it barks at me until I change it.
private void CreateRowRuleRMAHeadOpenRMAEquals_true()
{
// Description: AddMemoOnlyWhenClosed
// **** begin autogenerated code ****
RuleAction[] ruleActions = new RuleAction[0];
// Create RowRule and add to the EpiDataView.
// Dummy Context Object
object contextObject = null;
RowRule rrCreateRowRuleRMAHeadOpenRMAEquals_true = new RowRule("RMAHead.OpenRMA", RuleCondition.Equals, true, new RowRuleActionDelegate2(this.RMAHeadOpenRMAEqualstrue_CustomRuleAction), contextObject);
((EpiDataView)
//changed this next line to RMADtl
(this.oTrans.EpiDataViews["RMADtl"])).AddRowRule(rrCreateRowRuleRMAHeadOpenRMAEquals_true);
// **** end autogenerated code ****
}
private void RMAHeadOpenRMAEqualstrue_CustomRuleAction(Ice.Lib.ExtendedProps.RowRuleDelegateArgs args)
{
// ** RowRuleDelegateArgs Properties: args.Arg1, args.Arg2, args.Context, args.Row
// ** put custom Rule Action logic here
memoBtn.ReadOnly = true;
EpiDataView edvRmaDtl = (EpiDataView)(oTrans.EpiDataViews["RMADtl"]);
edvRmaDtl.SetCurrentRowProperty("AddCreditBtn", new ControlSettings() { IsEnabled = false });
}
Right, I did refactor it to make it like you showed. It’s simpler and better. But it does work the other way with a small tweak. Row rules are confusing to me for some reason. Thanks for your help.