private void EvaluateExpression(EbMobileControl ctrl, View view) { if (ctrl.HasExpression(ExpressionType.HideExpression)) { string script = ctrl.HiddenExpr.GetCode(); EbListHelper.SetDataRow(DataRow); view.IsVisible = !EbListHelper.EvaluateHideExpr(script); } else if (ctrl.HasExpression(ExpressionType.ValueExpression)) { string script = ctrl.ValueExpr.GetCode(); EbListHelper.SetDataRow(DataRow); EbListHelper.EvaluateValueExpr(view, script); } }
private void InitializeDependency(EbMobileControl control, string parent) { foreach (int value in Enum.GetValues(typeof(ExpressionType))) { if (control.HasExpression((ExpressionType)value, out string script)) { foreach (string dependent in GetDependentNames(script)) { string dparent = dependent.Split(CharConstants.DOT)[0]; if (dparent != CTRL_PARENT_FORM && parent == CTRL_PARENT_FORM)// grid to form dependency { if (!DGDependencyMapColl.ContainsKey(dparent)) { DGDependencyMapColl[dparent] = new ExprDependency(); } DGDependencyMapColl[dparent].Add((ExpressionType)value, $"{parent}.{control.Name}"); } else if (parent == dparent)// avoid form to grid dependency { if (!DependencyMapCollection.ContainsKey(dependent)) { DependencyMapCollection[dependent] = new ExprDependency(); } DependencyMapCollection[dependent].Add((ExpressionType)value, $"{parent}.{control.Name}"); } } } } }
public static void EvaluateExprOnLoad(EbMobileControl ctrl, FormMode mode) { string parent = ctrl.Parent; if (Instance.dependencyMap.HasDependency($"{parent}.{ctrl.Name}")) { ExprDependency exprDep = Instance.dependencyMap.GetDependency($"{parent}.{ctrl.Name}"); if (mode == FormMode.NEW || mode == FormMode.EDIT || mode == FormMode.PREFILL) { if (mode == FormMode.NEW || mode == FormMode.PREFILL) { Instance.InitHideExpr(exprDep, ctrl, parent); Instance.InitDisableExpr(exprDep, ctrl, parent); } else if (mode == FormMode.EDIT) { if (ctrl.DoNotPersist) { Instance.InitValueExpr(exprDep, ctrl.Name, parent); } Instance.InitHideExpr(exprDep, ctrl, parent); } } } else { if (mode == FormMode.NEW || mode == FormMode.EDIT || mode == FormMode.PREFILL) { if (ctrl.HasExpression(ExpressionType.HideExpression)) { Instance.EvaluateHideExpr(ctrl, parent); } if ((mode == FormMode.NEW || mode == FormMode.PREFILL) && ctrl.HasExpression(ExpressionType.DisableExpression)) { Instance.EvaluateDisableExpr(ctrl, parent); } } } }