- Home
- Forum
- ASP.NET MVC (Classic)
- Razor Layout / Grid Dropdownedit
Razor Layout / Grid Dropdownedit
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
SIGN IN To post a reply.
1 Reply
RR
Ranjithkumar R G
Syncfusion Team
February 14, 2013 04:00 AM UTC
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.
SIGN IN To post a reply.
- 1 Reply
- 2 Participants
-
JS Jon Stonis
- Feb 7, 2013 11:09 AM UTC
- Feb 14, 2013 04:00 AM UTC