I have just added the ForeignKey field template based on the old Futures Autocomplete filter to NuGet at NotAClue.DynamicData.AutocompleteForeignKey

Autocomplete in action
All you need is to add a UIHint attribute to the to set the field template,
Note: only works on Foreign Key columns
you can als0 set the number of characters you need to type before autocomplete kicks in.
[UIHint("Autocomplete", null, "MinimumPrefixLength",2)]
public Supplier Supplier { get; set; }
By setting the MinimumPrefixLength in the UIHint’s ControlParameters.




11 comments:
i saw in your posthow to upload an image to the database, but i am interested in uploading an image gallery , how can i dothis? what should i do?
Very helpful, thanks. Is there an equivalent for a filter?
hio FishOfPrey see http://csharpbits.notaclue.net/2011/06/second-nuget-package-for-dynamic-data.html it's one of these filters and was originally a filter in the old Futures project on aspnet.codeplex.com
Steve
I'm trying your package from NuGet and I have always the same exception:
"'customerID' is not a foreign key column and cannot be used here."
Where customerID is defined in metadata class as
[UIHint("Autocomplete",null, "MinimumPrefixLength",2)]
public global::System.Int32 customerID { get; set; }
Could it be a problem use Entity Data for DD? Your example seems to be with Linq2SQL.
Thx in advance,
Uri
no I have tested it wil EF and it works no problem. I will be supplying all the source code soon as I creating an OSS project on codeplex with all my stuff in.
Regards
Steve
Ups! sorry, it's true, and it works fine! :)
I was trying the autocomplete with the foreign key ID field not from Navigation Properties from the model.
I'm trying to fix a transparency problem with webkit based browsers.
Thanks for all your shared work!
Uri
Your welcome Uri :)
Steve
To fix the transparency bug (tested on FF, Chrone, Opera & Safari), we changed the ccs file.
.autocomplete_completionListElement {
[...]
background-color : window;/*inherit*/
[...]
}
Uri
Thanks Uri, I'll give that a try and add to the main project when i release on Codeplex.com
Steve
Hi Steve,
I think I found a bug (and a fix), when you add an entity from a filtered list where the filter is with an Autocomplete field, the filtered value is not traspassed to the new entity by default.
I changed the code in Autocomplete_Edit.asc.cs:
protected override void OnDataBinding(EventArgs e)
{
base.OnDataBinding(e);
if (Mode == DataBoundControlMode.Edit || Mode == DataBoundControlMode.Insert) /*changed*/
{
string selectedValueString = GetSelectedValueString();
if (selectedValueString.Trim().Length > 0) /*added*/
{
MetaTable parentTable = Column.ParentTable;
IQueryable query = parentTable.GetQuery();
// multi-column PK values are separated by commas
var singleCall = LinqExpressionHelper.BuildSingleItemQuery(query, parentTable, selectedValueString.Split(','));
var row = query.Provider.Execute(singleCall);
string display = parentTable.GetDisplayString(row);
AutocompleteTextBox.Text = display;
AutocompleteValue.Value = selectedValueString;
}
}
}
Hi oterrada, I have not seen that myself I will take you word for it thanks for posting.
Steve
Post a Comment