Exemplo n.º 1
0
        public IActionResult Load(FWDataOptionsViewModel bindModel)
        {
            var options = _memoryCache.Get <FWListOptions>(bindModel.CId);

            if (options == null)
            {
                return(StatusCode(500, "bad model"));
            }

            var filter = FWMapperHelper.Transform(options.FilterType, bindModel);

            FWModelHelper.BindFilterFromQueryString(filter, HttpContext.Request.Query);

            HttpContext.SetView(options.ViewPath);

            var service = _serviceProvider.GetService(options.ServiceType);
            var model   = options.ServiceMethod.Invoke(service, new object[] { filter }) as IEnumerable;

            // Gets the metadata from the return type of the service method.
            var metadata = _requestContext.MetadataProvider.GetMetadataForType(options.ServiceMethod.ReturnParameter.ParameterType);
            var control  = new FWListControl(_requestContext, metadata, model);

            foreach (var config in options.FluentConfiguration)
            {
                config.Invoke(control);
            }

            return(Content(control.ToString()));
        }
Exemplo n.º 2
0
 /// <summary>
 /// Allows the selection of Grid lines.
 /// </summary>
 /// <param name="allowSelect">Informs if the Grid allows selection.</param>
 /// <param name="selectionName">The name of the post field.</param>
 /// <returns>The fluent configurator object.</returns>
 public FWGridControl AllowSelect(bool allowSelect = true, string selectionName = null)
 {
     _allowSelect   = allowSelect;
     _selectionName = selectionName;
     if (allowSelect)
     {
         //Stores the key property
         _keyPropertyName = FWModelHelper.GetKeyProperty(base.ListType).Name;
     }
     return(this);
 }
Exemplo n.º 3
0
        /// <summary>
        /// Overrides the default CreateLine to add Grid behavior.
        /// </summary>
        /// <param name="lineobj">The object reference for the current line.</param>
        /// <returns>A FWTableLineElement object.</returns>
        protected override FWTableLineElement CreateLine(object lineobj)
        {
            var line = base.CreateLine(lineobj);

            if (_selection != null)
            {
                var lineKey = FWModelHelper.GetKeyPropertyValue(lineobj).ToString();
                //Changes the css of selected cells
                foreach (var selectedItem in _selection)
                {
                    if (selectedItem.ToString() == lineKey)
                    {
                        line.AddCssClass("warning");
                    }
                }
            }

            return(line);
        }