/// <summary>
        /// Invokes the view component.
        /// </summary>
        /// <param name="tableElementId">The ID of the table DOM element.</param>
        /// <param name="modelExplorer">The model explorer for the collection containing the table contents.</param>
        /// <param name="properties">The name of the properties of the model object to show in the table.</param>
        /// <param name="hiddenValues">Hidden values that should be included with the properties.</param>
        /// <param name="orderByProp">The property to order the rows by.</param>
        /// <param name="textAreas">Whether to render the properties in multi-line text areas.</param>
        /// <param name="startMinRows">The minimum number of rows in the table to start with.</param>
        /// <param name="defaultValues">The default values for each column, if any.</param>
        /// <param name="dropDownLists">The drop down lists to use, if any.</param>
        /// <param name="subPanelConfig">The configuration object for the subpanel (if any).</param>
        public IViewComponentResult Invoke(
            string tableElementId,
            ModelExplorer modelExplorer,
            string[] properties,
            IDictionary<string, string> hiddenValues,
            string orderByProp,
            int startMinRows,
            bool textAreas,
            IDictionary<string, object> defaultValues,
            IList<DropDownList> dropDownLists,
            SubPanelConfig subPanelConfig)
        {
            var props = properties.Where(prop => prop != null).ToArray();
            var collection = GetOrderedCollection(modelExplorer, orderByProp);
            var elementMetadata = modelExplorer.Metadata.ElementMetadata;
            string collectionName = modelExplorer.Metadata.PropertyName;

            JArray columns = GetColumnInfo
            (
                props,
                hiddenValues,
                textAreas,
                defaultValues,
                dropDownLists,
                elementMetadata
            );

            var initDataProperties = subPanelConfig == null
                ? props
                : props.Union(new[] { subPanelConfig.ContentsPropertyName });

            JArray initData = GetInitialData
            (
                hiddenValues,
                collection,
                dropDownLists,
                elementMetadata,
                initDataProperties
            );

            return View
            (
                new DynamicTableConfig
                (
                    tableElementId,
                    collectionName,
                    columns,
                    initData,
                    startMinRows,
                    textAreas,
                    dropDownLists,
                    subPanelConfig
                )
            );
        }
Exemplo n.º 2
0
 /// <summary>
 /// Constructor
 /// </summary>
 public DynamicTableConfig(
     string tableElementId,
     string collectionName,
     JArray columns,
     JArray initData,
     int startMinRows,
     bool textAreas,
     IList<DropDownList> dropDownLists,
     SubPanelConfig subPanelConfig)
 {
     TableElementId = tableElementId;
     CollectionName = collectionName;
     Columns = columns;
     InitData = initData;
     StartMinRows = startMinRows;
     TextAreas = textAreas;
     DropDownLists = dropDownLists;
     SubPanelConfig = subPanelConfig;
 }
Exemplo n.º 3
0
 /// <summary>
 /// Constructor
 /// </summary>
 public DynamicTableConfig(
     string tableElementId,
     string collectionName,
     JArray columns,
     JArray initData,
     int startMinRows,
     bool textAreas,
     JObject hideButtons,
     IList <DropDownList> dropDownLists,
     SubPanelConfig subPanelConfig)
 {
     TableElementId = tableElementId;
     CollectionName = collectionName;
     Columns        = columns;
     InitData       = initData;
     StartMinRows   = startMinRows;
     TextAreas      = textAreas;
     HideButtons    = hideButtons;
     DropDownLists  = dropDownLists;
     SubPanelConfig = subPanelConfig;
 }