This is a migrated thread and some comments may be shown as answers.
Strange ComboBox issue when returning a view
0 Answers 13 Views
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Tom
Top achievements
Rank 1
Tom asked on 03 Nov 2011, 03:27 PM
Environment:

ASP.NET MVC 3 
C#
Razor ViewEngine
Telerik MVC v.2011.2.712.340
 
I'm using the below code to set a combobox (within a form) text via a value when a page is loaded
@(Html.Telerik().ScriptRegistrar().Globalization(true).DefaultGroup(group => group.Combined(true).Compress(true)).OnDocumentReady(@<text> 
          //Select EU
        var Ticket_EndUserID = $("#Ticket_EndUserID").val();
        var TicketEU = $('#TicketEU').data('tComboBox');
        var selectEUItem = function (dataEUItem) {
            return dataEUItem.Value == Ticket_EndUserID;
        }
        TicketEU.fill(function () { //binds the combobox
            TicketEU.select(selectEUItem);
        })
</text>))

This work fine. Ths issue is when the form is submitted and I return the view with errors the combobox just has the value in the combobox field instead of the text.

If I comment out the above like below then when I return the view with errors the comobox has the text in instead of the vaule, which is correct. But when the page is loaded the combobox has no vaul/text:
@(Html.Telerik().ScriptRegistrar().Globalization(true).DefaultGroup(group => group.Combined(true).Compress(true)).OnDocumentReady(@<text> 
  
       @* //Select EU
        var Ticket_EndUserID = $("#Ticket_EndUserID").val();
          
        var TicketEU = $('#TicketEU').data('tComboBox');
        var selectEUItem = function (dataEUItem) {
            return dataEUItem.Value == Ticket_EndUserID;
        }
        TicketEU.fill(function () { //binds the combobox
            TicketEU.select(selectEUItem);
        })*@  
        </text>))


Tags
ComboBox
Asked by
Tom
Top achievements
Rank 1
Share this question
or