Ejemplo n.º 1
0
        private IFWHtmlElement CreateGrid()
        {
            FWPortletControl grid = new FWPortletControl(Id, FWStringLocalizer.GetViewResource(Id));

            grid.DataType("fw-grid");
            grid.Attributes.Add("data-key", _cacheKey);

            grid.Attributes.AddRange(Attributes);
            if (!string.IsNullOrWhiteSpace(CustomCss))
            {
                grid.AddCssClass(CustomCss);
            }
            // Clears custom attributes and css to prevent adding to the base table control.
            Attributes.Clear();
            ClearCss();

            grid.Attributes.Add("data-url", RequestContext.Url.Action("Load", "FWGrid", new { area = string.Empty }));

            //Adds the grid body to the control.
            FWDivElement detailGridBody = CreateGridBody();

            grid.Add(detailGridBody);

            if (_allowSelect)
            {
                CreateGridSelection(grid);
            }

            return(grid);
        }
Ejemplo n.º 2
0
        private IFWHtmlElement CreateList()
        {
            FWPortletControl list = new FWPortletControl(Id, FWStringLocalizer.GetViewResource(Id))
            {
                Id = Id
            };

            list.DataType("fw-list");
            list.Attributes.Add("data-key", _cacheKey);

            list.Attributes.AddRange(Attributes);
            if (!string.IsNullOrWhiteSpace(CustomCss))
            {
                list.AddCssClass(CustomCss);
            }

            list.Attributes.Add("data-url", RequestContext.Url.Action("Load", "FWList", new { area = string.Empty }));

            // Adds the list body to the control.
            FWDivElement detailListBody = CreateListItems();

            list.Add(detailListBody);

            return(list);
        }
        /// <summary>
        /// Creates the control main element.
        /// </summary>
        /// <returns>The IFWHtmlElement object representation of the control.</returns>
        protected override IFWHtmlElement CreateControl()
        {
            CreateLineActions();

            var detailControl = new FWPortletControl(Id, GetModelResource(OriginalId));

            detailControl.AddCssClass("fw-detail-table");
            detailControl.DataType("fw-detailcontrol");

            detailControl.Attributes.Add("data-model", ListType.Name);

            detailControl.AddAction(FWDetailHelper.CreateUndoButton());

            detailControl.Required(Metadata.IsRequired);

            detailControl.Footer(FWDetailHelper.CreateAddButton().ToString());

            detailControl.Attributes.AddRange(Attributes);
            if (!string.IsNullOrWhiteSpace(CustomCss))
            {
                detailControl.AddCssClass(CustomCss);
            }
            // Clears custom attributes and css to prevent adding to the base table control.
            Attributes.Clear();
            ClearCss();

            var grid = base.CreateControl() as FWTagBuilder;

            grid.DataType = "fw-detailcontrol-body";
            grid.Attributes.Add("role", "grid");

            detailControl.Add(grid);

            if (Metadata.IsRequired)
            {
                var validationDiv = new FWDivElement();
                {
                    validationDiv.DataType = "fw-detailvalidation";
                    validationDiv.AddCssClass("m-form__group form-group");

                    //Creates the validation input
                    var validationInput = new FWInputElement("DetailValidation", FWInputType.Hidden);
                    validationInput.Attributes.Add("data-rule-requireddetail", Metadata.IsRequired.ToString().ToLower());
                    validationInput.Attributes.Add("data-msg-requireddetail", string.Format(ViewResources.Validation_Required_Detail, GetModelResource(OriginalId)));
                    validationInput.Attributes.Add("data-skipvalidation", "false");

                    validationDiv.Add(validationInput);

                    detailControl.Add(validationDiv);
                }
            }

            detailControl.Add(RegisterTemplate());

            return(detailControl);
        }
        /// <summary>
        /// Creates the control main element.
        /// </summary>
        /// <returns>The IFWHtmlElement object representation of the control.</returns>
        protected override IFWHtmlElement CreateControl()
        {
            var detailControl = new FWPortletControl(Id, GetModelResource());

            detailControl.AddCssClass("fw-detail-grid");
            detailControl.DataType("fw-detailcontrol");

            detailControl.Attributes.Add("data-model", _listType.Name);

            detailControl.AddAction(FWDetailHelper.CreateUndoButton());

            detailControl.Required(IsRequired);

            detailControl.Footer(FWDetailHelper.CreateAddButton().ToString());

            detailControl.Attributes.AddRange(Attributes);
            if (!string.IsNullOrWhiteSpace(CustomCss))
            {
                detailControl.AddCssClass(CustomCss);
            }

            var body = new FWDivElement()
            {
                DataType = "fw-detailcontrol-body"
            };

            if (Model != null)
            {
                int i    = 0;
                var list = Model as IEnumerable;
                foreach (var item in list)
                {
                    body.Add(CreateBody(item, i.ToString()));
                    i++;
                }
            }

            detailControl.Add(body);

            if (IsRequired)
            {
                var validationDiv = new FWDivElement();
                {
                    validationDiv.DataType = "fw-detailvalidation";
                    validationDiv.AddCssClass("m-form__group form-group");

                    //Creates the fileupload validation input
                    var validationInput = new FWInputElement("DetailValidation", FWInputType.Hidden);
                    validationInput.Attributes.Add("data-rule-requireddetail", "true");
                    validationInput.Attributes.Add("data-msg-requireddetail", string.Format(ViewResources.Validation_Required_Detail, GetModelResource()));
                    validationInput.Attributes.Add("data-skipvalidation", "false");

                    validationDiv.Add(validationInput);

                    detailControl.Add(validationDiv);
                }
            }

            detailControl.Add(RegisterTemplate());

            return(detailControl);
        }