We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

The selected item does not display in textbox of GenericDropDown

The selected item (Name) does not display in textbox of GenericDropDown.  The initial value appeared in the textbox but when I make different item in the popup panel, the new item does not show up.  I do not have images in my selection list but I don't think that would make it not working.  Help!

In Controller, I have the following:

            ViewBag.selectedBeforeEvents = db.Ratings.Where(e => e.Type == 1 && e.Scale == threat.LOIBeforeEvent).Single().Name;
            ViewBag.LOIBeforeEvents = db.Ratings.Where(e => e.Type == 1).ToList();

In View, I have the following:

 @{List<gThiraMetrix.Models.Rating> LOIBeforeEventList = ViewBag.LOIBeforeEvents;
       string selectedBeforeEvent = ViewBag.selectedBeforeEvents;
       Html.Syncfusion().GenericDropDown("LOIBeforeEventPopup")
                .DataSource(LOIBeforeEventList)
                .Text(selectedBeforeEvent)
                .BindTo(bind=>
               bind.Text("Name")
                        .Id("RatingID")).Render();}


3 Replies

ME Meena Syncfusion Team March 12, 2013 05:15 AM UTC

Hi Marie,

 

Thanks for contacting Syncfusion forums.

 

Your requirement of updating the text of selected item in GenericDropdown textbox can be achieved using the “setText()” client side method. Please refer the below code snippet,

 

<code>

@{Html.Syncfusion().GenericDropDown("myGenericDropDown").ClientSideOnClick("ClientSideOnClick").Render();}                    // This event will be triggered on item select

 

[Script]

 

function ClientSideOnClick(sender, args) {

        var text = "";

        if (args._target.nodeName.toLowerCase() == "img")

            text = $(args._target.parentNode).text().trim();

        else

            text = args._text;

        sender.setText(text);                                                                                                  // This method will set the text in textbox

    }

 

</code>

 

We have also prepared a simple sample with GenericDropdown with databinding as per your code snippet and it can be downloaded from the below link.

 

Kindly have a look at the sample and let us know if your requirement is met.

 

Regards,

Meena



F107668_GDD_42d16956.zip


MC Marie CG March 12, 2013 06:57 PM UTC

Thank you.  It is working.
Marie


ME Meena Syncfusion Team March 13, 2013 04:40 AM UTC

Hi Marie,

 

Thanks for the update.

 

We are glad to know that your issue has been solved. Kindly get back to us if you need further assistance.

 

We will be happy to help you out.

 

Regards,

Meena


Loader.
Live Chat Icon For mobile
Up arrow icon