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

[Solved] ComboBox Rebind on Open?

2 Answers 177 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.
Sean
Top achievements
Rank 1
Sean asked on 21 Mar 2011, 03:26 AM
I have a number of form fields that I bind that are dependent on other field values. Is there some way to tell the ComboBox to rebind every time it is opened? In this example if someone changes the State, the zip codes in the list are no longer valid.

function

 

 

Zip_AutoComplete(e) {

 

 

    e.data = $.extend({}, e.data, { state: $(

 

"#State").val(), city: $("#City").val() });

 

 

}

 

 

@(Html.Telerik().AutoComplete()

 

.Name(

 

 

"Zip")

 

 

.Encode(

 

 

false)

 

 

.Filterable(f => f.FilterMode(

 

 

AutoCompleteFilterMode.Contains))

 

 

.HighlightFirstMatch(

 

 

true)

 

 

.ClientEvents(events => events.OnDataBinding(

 

 

"Zip_AutoComplete"))

 

 

.DataBinding(a => a.Ajax().Select(

 

 

"ZipList", "Rat"))

 

 

.AutoFill(

 

 

true)

 

 

.HtmlAttributes(

 

 

new { style = string.Format("width:{0}px", 90) })

 

 

)

 

 

[

 

 

Authorize]

 

 

 

 

 

public ActionResult ZipList(string text, string state, string city) {

 

 

 

 

 

    var zips = _entities.Locations.Where(l => l.State == state

 

 

        && (city.Length == 0 || l.City.StartsWith(city)))

 

        .Select(l => l.ZipCode).Distinct()

 

        .OrderBy(o => o)

 

        .ToList();

 

 

 

 

    return new JsonResult { Data = zips };

 

 

}

2 Answers, 1 is accepted

Sort by
0
Stanislav
Top achievements
Rank 1
answered on 25 May 2011, 09:08 AM
I think this is a valid question, found any solution to it? I'm surprised no one from the Telerik Team helped.
0
Stanislav
Top achievements
Rank 1
answered on 25 May 2011, 12:16 PM
Tags
ComboBox
Asked by
Sean
Top achievements
Rank 1
Answers by
Stanislav
Top achievements
Rank 1
Share this question
or