Exemple #1
0
        private void AddPropertyField <TProperty>(RenderTreeBuilder pBuilder, IMGridColumn pColumn, IMGridPropertyColumn pPropertyColumn, bool pIsInFilterRow, double pLeftOffset, BoundingBox pBoundingBox)
        {
            var attributes = mPropertyInfoCache[pPropertyColumn].GetAttributes()?.ToList() ?? new List <Attribute>();

            if (pIsInFilterRow)
            {
                if (!pColumn.EnableFilter && !attributes.OfType <ReadOnlyAttribute>().Any())
                {
                    attributes.Add(new ReadOnlyAttribute());
                }
                if (pColumn.EnableFilter && attributes.Any(a => a is ReadOnlyAttribute))
                {
                    attributes = attributes.Where(a => !(a is ReadOnlyAttribute)).ToList();
                }
            }

            if (pColumn is IMGridComplexEditableColumn <TProperty> complex)
            {
                if (pIsInFilterRow)
                {
                    pBuilder.OpenComponent <MComplexPropertyField <ExpandoObject, TProperty> >(5);
                }
                else
                {
                    pBuilder.OpenComponent <MComplexPropertyField <T, TProperty> >(5);
                }

                pBuilder.AddAttribute(776, "Property", pPropertyColumn.Property);
                pBuilder.AddAttribute(777, "PropertyType", typeof(TProperty));
                pBuilder.AddAttribute(778, "Attributes", attributes.ToArray());

                if (complex.FormTemplate != null && !pIsInFilterRow || (pIsInFilterRow && pColumn.EnableFilter))
                {
                    pBuilder.AddAttribute(781, "Template", complex.FormTemplate);
                }


                pBuilder.AddStyleWithAttribute(784, Extensions.MFORM_IN_TABLE_ROW_TD_STYLE_ATTRIBUTE, pLeftOffset, pBoundingBox);

                pBuilder.CloseComponent();
            }
            else
            {
                pBuilder.OpenComponent <MField>(790);

                pBuilder.AddAttribute(792, "Property", pPropertyColumn.Property);
                pBuilder.AddAttribute(793, "PropertyType", typeof(TProperty));
                pBuilder.AddAttribute(794, "Attributes", attributes.ToArray());

                pBuilder.AddStyleWithAttribute(976, Extensions.MFORM_IN_TABLE_ROW_TD_STYLE_ATTRIBUTE, pLeftOffset, pBoundingBox);

                pBuilder.CloseComponent();
            }
        }
Exemple #2
0
 private void AddFieldGenerator(RenderTreeBuilder pBuilder, IMGridEditFieldGenerator <T> pFieldGenerator, bool pIsInFilterRow, double pLeftOffset, BoundingBox pBoundingBox)
 {
     pBuilder.OpenElement(804, "td");
     pBuilder.AddStyleWithAttribute(805, "style", pLeftOffset, pBoundingBox);
     pBuilder.AddContent(806, pFieldGenerator.EditFieldTemplate(pLeftOffset, pBoundingBox, pIsInFilterRow));
     pBuilder.CloseElement();
 }