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

Persist value that is not in the combo box list

5 Answers 76 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.
Barry
Top achievements
Rank 1
Barry asked on 14 Feb 2011, 09:09 AM
I have a combo box that is binded to my Viewdata.

ViewData[

 

"SampleList"] = new SelectList(data, "Name", "Name");

In my View, I access my ViewData and bind it to the combobox

 

 

<%

 

= Html.Telerik().ComboBoxFor(model => model.name) 
        .BindTo((
SelectList)ViewData["SampleList"]) %>

This codes works. The problem is that whenever I input any data(not available in the provided list) in my combobox, after submiting a form or any triggering a postback, the value becomes lost and resets back.

What I want to achieve here is that even though there is a given list, I want the user to have the flexibility to input what ever they want.

Please advice

 

5 Answers, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 14 Feb 2011, 12:48 PM
Hello Barry,

 
I believe that the ComboBox UI component will preserve user's input through PostBacks. You can test it on this online demo.
If you need to add custom text to the list of items, then you should new item to the SampleList collection on PostBack.

All the best,
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
Barry
Top achievements
Rank 1
answered on 18 Feb 2011, 01:41 AM

Thanks for the response.

I was able to visit the sample, but still I can see why is it not working in my solution. I even tried using only

<%= Html.Telerik().ComboBoxFor(model => model.name) %>

I did not even bind my viewData, upon debugging, model.name has "Barry" value. But upon rendering of page, the value does not appear.

I am using telerik version 2010.3.1110.235. If possible, can you please make a sample project where I can refer? Make it short and simple, just show how could I persist data in the comboBoxFor.

Please advice

0
Georgi Krustev
Telerik team
answered on 18 Feb 2011, 08:59 AM
Hello Barry,

 
Persisting values from PostBack is not supported in 2010.3.1110 version. I will suggest you upgrade to the latest official version of Telerik Components for ASP.NET MVC.

As to the demo, our online demos are distributed  with the Telerik Components for ASP.NET MVC. You can download them and refer to the ComboBox/ClientValidation.aspx page. It shows how simply and really straightforward to achieve your goal.

Kind regards,
Georgi Krustev
the Telerik team
0
Barry
Top achievements
Rank 1
answered on 21 Feb 2011, 02:18 AM
Hi Georgi,

I downloaded the latest version for MVC 2 version 2010.3.1318.235. I referred to the samples that are available but unfortunately I observed that the values only persist after I give focus to the combo box.  Please see attached screenshot.

 Anyway, I was able to fix this by modifying the telerik.combobox.min.js. I just repopulated the textbox when initializing the textbox

 

 

var p = this

.trigger;

 

 

 

 

 

 

var o = this

.dropDown;

 

 

 

 

 

 

if

(!o.$items) {

 

 

 

 

 

 

this

.fill(p.$text);

 

 

}

 


0
Georgi Krustev
Telerik team
answered on 24 Feb 2011, 09:05 AM
Hello Barry,

 
Unfortunately I am still not able to reproduce the depicted issue on our online demo, which runs upon version 2010.3.1318 of the Telerik Components for ASP.NET MVC. If the problem still persists I will suggest you send us a simple test project, where we can observe the depicted issue.

Best wishes,
Georgi Krustev
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
Tags
ComboBox
Asked by
Barry
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
Barry
Top achievements
Rank 1
Share this question
or