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.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Razor Layout / Grid Dropdownedit

Thread ID:

Created:

Updated:

Platform:

Replies:

107011 Feb 7,2013 11:09 AM UTC Feb 14,2013 04:00 AM UTC ASP.NET MVC (Classic) 1
loading
Tags: Grid
Jon Stonis
Asked On February 7, 2013 11:09 AM UTC

So I can see how you this:
                cols.Add(c => c.phoneNumberId).HeaderText("PhoneId").Visible(false);
                cols.Add(c => c.phoneTypeName).HeaderText("Phone Type").CellEditType(CellEditType.DropdownEdit);
               
                cols.Add(c => c.phoneNumber).HeaderText("Phone Number").AllowEditing(true);

This works fine, but the dropdown edit only takes the unique values from the data you gave it.  If I have only 1 row of data and 7 phone types, how can I display all 7 phone types.  Seems like there needs to be a way to pass in the "extra" values in the drop down that are not represented in the data.

Jon

Ranjithkumar R G [Syncfusion]
Replied On February 14, 2013 04:00 AM UTC

Hi Jon ,

 

Thanks for using Syncfusion products.

 

We would like to let you know that as per our current implementation, when we specify celledit type as dropdownlist, we used to display distinct values in the dropdown. If you need to specify your own custom values in dropdown, we suggest you to refer to the below code snippet.

 

[Script]

 

 <%=Html.Syncfusion().Grid<EditableOrder>("SampleGrid")
                        .ClientSideEvents(events =>
                        {
                            events.OnRecordEdit("SetdropDownData");
                        })         

 

     %>

 

 

[Script]

 

function SetdropDownData(sender, args) {
             $.ajax({
                 type: "POST",
                 url: "Editing/GetCountries",
                 dataType: "json",
                 success: function (data) {
                     $("#ShipCountry option").remove();
                     $.each(data, function (index, val) {
                         var optionTag = $("<option></option>");
                         $(optionTag).val(val.Value).text(val.Text);
                         $("#ShipCountry").append(optionTag);
                     });
                     $("#ShipCountry").val(selectedCountry);
                 }
             });
        
     }

 

 

[Controller]

    public ActionResult GetCountries()
        {
            return Json(CountryList, JsonRequestBehavior.AllowGet);
        }
      
  public IEnumerable<SelectListItem> CountryList
        {
            get
            {
 
                List<SelectListItem> type = new List<SelectListItem>();
                type.Add(new SelectListItem
                {
                    Selected = true,
                    Text = "Switzerland",
                    Value = "Switzerland"
                });
                type.Add(new SelectListItem
                {
 
                    Text = "Brazil",
                    Value = "Brazil"
                });
                type.Add(new SelectListItem
                {
                    Text = "Germany",
                    Value = "Germany"
                });
                type.Add(new SelectListItem
                {
 
                    Text = "Mexico",
                    Value = "Mexico"
                });
 
                type.Add(new SelectListItem
                {
 
                    Text = "USA",
                    Value = "USA"
                });
 
 
                type.Add(new SelectListItem
                {
 
                    Text = "Spain",
                    Value = "Spain"
                });
                return type;
            }
        }

 

 

Sample link: Sample.zip

 

Please let us know if you have any concern.

 

Regards,

Ranjithkumar.


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;