Ejemplo n.º 1
0
 /// <summary>
 /// Renders the controls.
 /// </summary>
 /// <param name="entityType">Type of the entity.</param>
 /// <param name="filterControl">The filter control.</param>
 /// <param name="writer">The writer.</param>
 /// <param name="controls">The controls.</param>
 public override void RenderControls( Type entityType, FilterField filterControl, HtmlTextWriter writer, Control[] controls )
 {
     if ( controls.Length > 0 )
     {
         DropDownList ddlEntityField = controls[0] as DropDownList;
         var entityFields = EntityHelper.GetEntityFields( entityType );
         RenderEntityFieldsControls( entityType, filterControl, writer, entityFields, ddlEntityField, controls.ToList(), filterControl.ID );
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Sets the selection.
        /// </summary>
        /// <param name="entityType"></param>
        /// <param name="controls">The controls.</param>
        /// <param name="selection">The selection.</param>
        public override void SetSelection( Type entityType, Control[] controls, string selection )
        {
            if ( !string.IsNullOrWhiteSpace( selection ) )
            {
                var values = JsonConvert.DeserializeObject<List<string>>( selection );

                DropDownList ddlProperty = controls[0] as DropDownList;
                var entityFields = EntityHelper.GetEntityFields( entityType );
                SetEntityFieldSelection( entityFields, ddlProperty, values, controls.ToList() );
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Gets the selection.
        /// </summary>
        /// <param name="entityType"></param>
        /// <param name="controls">The controls.</param>
        /// <returns></returns>
        public override string GetSelection( Type entityType, Control[] controls )
        {
            var values = new List<string>();

            if ( controls.Length > 0 )
            {
                DropDownList ddlProperty = controls[0] as DropDownList;

                var entityFields = EntityHelper.GetEntityFields( entityType );
                var entityField = entityFields.FirstOrDefault( f => f.Name == ddlProperty.SelectedValue );
                if ( entityField != null )
                {
                    var control = controls.ToList().FirstOrDefault( c => c.ID.EndsWith( entityField.Name ) );
                    if ( control != null )
                    {
                        values.Add( ddlProperty.SelectedValue );
                        entityField.FieldType.Field.GetFilterValues( control, entityField.FieldConfig ).ForEach( v => values.Add( v ) );
                    }
                }
            }
            return values.ToJson();
        }