/// <summary> /// Creates a field that will contain a value of a specific type /// </summary> public static FormField CreateField(Type type) { //validate arguments if (type == null) { throw new ArgumentNullException("type"); } //field FormField field; //The type is a persistent type if (DataType.IsMapped(type)) { field = new ObjectListPickerField(DataType.GetMap(type)); //if it's a short list, create a DropDown /*if (DataBase.Current.Count(type) <= 100) * { * field = new DataObjectListPickerField(); * } * //otherwise create an autocomplete * else * { * field = new DataObjectAutoCompleteField(); * }*/ } //DataType else if (type.Equals(typeof(DataType))) { field = new DataTypeField(); } //just create a simple field for common values else { field = FormField.CreateFieldFrom(type); } //return return(field); }
/// <summary> /// Creates a field that will contain a value of a specific type /// </summary> public static FormField CreateField(Type type) { //validate arguments if (type == null) throw new ArgumentNullException("type"); //field FormField field; //The type is a persistent type if (DataType.IsMapped(type)) { field = new ObjectListPickerField(DataType.GetMap(type)); //if it's a short list, create a DropDown /*if (DataBase.Current.Count(type) <= 100) { field = new DataObjectListPickerField(); } //otherwise create an autocomplete else { field = new DataObjectAutoCompleteField(); }*/ } //DataType else if (type.Equals(typeof(DataType))) { field = new DataTypeField(); } //just create a simple field for common values else { field = FormField.CreateFieldFrom(type); } //return return field; }
/// <summary> /// Creates a field that will contain a value of a specific type /// <para xml:lang="es"> /// Crea un campo que contendra un valor de un tipo especifco /// </para> /// </summary> public static FormField CreateFieldFrom(Type type) { //validate arguments if (type == null) throw new ArgumentNullException("type"); //field FormField field; //The type is a persistent type if (DataType.IsMapped(type)) { var select = new Operations.Select(); select.DataType = type; field = new ObjectListPickerField(select); ////show total records //Operations.SelectAggregate count = new Operations.SelectAggregate(); //count.DataType = type; //count.AggregateMembers.Add(new Operations.SelectAggregateMember(select.DataType.PrimaryKey.First(), Operations.SelectAggregateFunction.Count)); //int totalRecords = 0; //using (var db = DataBase.CreateDataBase()) //{ // totalRecords = Data.Convert.ChangeType<int>(db.SelectScalar(count)); //} ////if it's a short list, create a DropDown //if (totalRecords <= 100) //{ // field = new ObjectListPickerField(select); //} ////otherwise create an autocomplete //else //{ // field = new ObjectAutoCompleteField(select); //} } //DataType else if (type.Equals(typeof(DataType))) { field = new DataTypeField(); } //just create a simple field for common values else { field = FormField.CreateFieldFrom(type); } //return return field; }