Ejemplo n.º 1
0
        internal string PrepareConnections(RowType row)
        {
            if (ColumnConnection != null || For == null || string.IsNullOrEmpty(For.Metadata.PropertyName))
            {
                return(null);
            }
            var pres = row?.For?.Metadata?.ModelType?.GetTypeInfo()?.GetProperty(For.Metadata.PropertyName)?
                       .GetCustomAttribute <ColumnConnectionAttribute>(false);

            if (pres == null)
            {
                return(null);
            }
            else
            {
                ColumnConnection = pres.GetConnection(row);
                return(ColumnConnection.DisplayProperty.Metadata.PropertyName);
            }
        }
Ejemplo n.º 2
0
        public RowType(ModelExpression expression,
                       uint inheritIndex,
                       bool isDetail = false,
                       IEnumerable <Column> addColumns    = null,
                       IEnumerable <string> removeColumns = null,
                       Func <IEnumerable <Column>, ContextualizedHelpers, object, IHtmlContent> renderHiddens = null,
                       bool?queryEnabled = null)
        {
            IsDetail = isDetail;
            For      = expression;
            init     = x =>
            {
                RowType inheritFrom = null;
                string  keyName     = null;
                if (x != null && inheritIndex < x.Count && inheritIndex >= 0)
                {
                    inheritFrom = x[(int)inheritIndex];
                    keyName     = inheritFrom.KeyName;
                }

                this.renderHiddens = renderHiddens;
                if (inheritFrom == null || inheritFrom.Columns == null)
                {
                    throw new ArgumentNullException(nameof(inheritFrom));
                }
                if (keyName == null)
                {
                    KeyName = GetConventionKey(For.Metadata.ModelType);
                    if (KeyName == null)
                    {
                        throw new ArgumentException(DefaultMessages.NoRowKey, nameof(keyName));
                    }
                }
                else
                {
                    KeyName = keyName;
                }
                InheritColumns(inheritFrom.visibleAndHiddenColumns, addColumns, removeColumns, true);
                QueryEnabled = queryEnabled;
                PrepareColumns();
            };
        }