This is a migrated thread and some comments may be shown as answers.

[Solved] LoadOnDemand and server side validation

7 Answers 168 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
montgomery
Top achievements
Rank 1
montgomery asked on 20 Aug 2010, 01:26 AM
In another thread (http://www.telerik.com/community/forums/aspnet-mvc/combobox/pasting-value-not-binding.aspx) it was mentioned that "...the combobox and autocomplete will save its value through postbacks." in the upcoming release.
 
I've been playing around with LoadOnDemand and ComboBoxes for our new project. I like having the ComboBox living in an EditorTemplate and with the load on demand I can easily reuse the same ComboBox for many different properties around the web app using the DataType attribute. However, I also noticed that upon a failed server validation, presumably since the ComboBox is not yet loaded, no selected ComboBox values are retained. The user not only has to fix the problem that triggered validation, they also need to re-select the values in the ComboBox(es). Will the comment in the paragraph above apply to a load on demand ComboBox as well?

7 Answers, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 20 Aug 2010, 08:02 AM
Hello David,

The ComboBox UI component, which will come with the official release, will preserve and repopulate selected item or custom value send to the server. Thus entered value into combobox input element will be repopulate, irrelevant to its validity. Is this behavior cover your needs ?

Regards,
Georgi Krustev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
montgomery
Top achievements
Rank 1
answered on 20 Aug 2010, 05:07 PM
It sounds like it will work exactly as needed. My hope is that it will retain values after postback and failed server validation for both load on demand and server binding.
0
Georgi Krustev
Telerik team
answered on 23 Aug 2010, 09:12 AM
Hello montgomery,

ComboBox UI will behave exavtly the way you wanted. You will be able to check it later this month, when the official release is scheduled.

Kind regards,
Georgi Krustev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
John
Top achievements
Rank 2
answered on 12 Oct 2010, 03:12 AM
Hi Georgi

You mentioned in a previous post that ComboBox UI component preserve and repopulate on post back.

Is it possible for the AutoComplete UI component to do the same as it is blank on intial load.

Hope this is clear.

John
0
Georgi Krustev
Telerik team
answered on 12 Oct 2010, 09:03 AM
Hello John,

AutoComplete UI complete will preserve its value after post back. Actually DropDownList, ComboBox and AutoComplete UI component will preserve their value after post back. You can use our server validation example as a base for your test.

Kind regards,
Georgi Krustev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
John
Top achievements
Rank 2
answered on 12 Oct 2010, 10:08 PM
Hi Georgi

Thanks for reply.  Unfortunately i am not using an ID on the field so unable to use example.  The purpose of the field is to allow the user to autocomplete name from a possible names list of names previous eneyterde in the system.  The dont have to pick one and create anything.  The default value is the field that was last on the database.  As a workaround to acheived the desire resuilt when editing the form is i use jquery to populate the value.  Hopefully i have put enough code below to demonstrate what i trying to acheive.

<%: Html.Telerik.AutoCompleteFor(Function(model) model.Claimant1FirstName) _
                                .Filterable(Function(filtering) {
                                    filtering.FilterMode(AutoCompleteFilterMode.Contains),
                                    filtering.MinimumChars(3)}) _
                                .DataBinding(Function(binding) binding.Ajax().Select("_AjaxClaimantNameAuto", "Job").Delay(400).Cache(True)) _
                                .HighlightFirstMatch(False) _
                                .HtmlAttributes(New With {.style = "width:300px"}) _
                                .ClientEvents(Function(events) events.OnChange("updateClaimant1FirstName"))%>

the Ajax handler is

Function _AjaxClaimantNameAuto(ByVal text As String) As ActionResult
    Dim _list = EntityHelper.GetClaimantNameList(text)
    Dim _sl = New SelectList(_list)
    Dim _json As New JsonResult With {.Data = _sl, .JsonRequestBehavior = JsonRequestBehavior.AllowGet}
    Return _json
End Function

 and the linq query is

Public Shared Function GetClaimantNameList(ByVal text As String) As List(Of String)
    Dim _AIMSContext As AIMS.Linq.AIMSContext.AIMSContext = AIMS.Linq.AIMSLinqHelper.GetAIMSContext
    Dim _list = _
        From JobAutocompleteName In _AIMSContext.JobAutocompleteNames _
        Where JobAutocompleteName.Name.StartsWith(text, StringComparison.CurrentCultureIgnoreCase) _
        Order By JobAutocompleteName.Name _
        Select JobAutocompleteName.Name
    Return _list.ToList
End Function

0
Georgi Krustev
Telerik team
answered on 13 Oct 2010, 04:17 PM
Hello John,

Unfortunately the required functionality is not currently supported. We will try to include support for setting value of the Autocomplete UI component through Model.Property for the next official release of Telerik components for ASP.NET MVC.

For the now, as you said, you can use jQuery to set value or use HtmlAttributes to add value attribute to the rendered HTML input element.

Regards,
Georgi Krustev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
ComboBox
Asked by
montgomery
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
montgomery
Top achievements
Rank 1
John
Top achievements
Rank 2
Share this question
or