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); }
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); }
private void CreateGridSelection(FWPortletControl detailGrid) { detailGrid.Attributes.Add("data-allowselect", "true"); //Adds the selection legend var legend = new FWElementGroup(); var legendIcon = new FWSpanElement(); legendIcon.AddCssClass("text-warning"); legendIcon.Add("<i class=\"fa fa-square\"></i>"); legend.Add(legendIcon); var legendText = new FWSpanElement(); legendText.Add(ViewResources.Selected); legend.Add(legendText); detailGrid.AddAction(legend.ToString()); //Adds the hidden post input var postInputHolder = new FWDivElement() { DataType = "fw-grid-selection", Id = _selectionName ?? Id }; if (_selection != null) { StringBuilder sb = new StringBuilder("["); //Adds the selected items to the grid foreach (var item in _selection) { if (sb.Length > 1) { sb.Append(","); } sb.Append(item.ToString()); } sb.Append("]"); postInputHolder.Attributes.Add("data-selected", sb.ToString()); } detailGrid.Add(postInputHolder); }
/// <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); }