<script>
function complete(args) {
if ((args.requestType == "beginedit" || args.requestType == "add") && args.model.editSettings.editMode == "dialogtemplate") {
$('#OrderID').ejDropDownList(
{
dataSource: @Html.Raw(Json.Serialize(@ViewBag.dataSource)),
fields: {
text: "orderID",
value: "orderID"
}
}
);
}
}
</script> |
Hi Keerthana
Thanks for the feedback, i try to use the code that has been shared as reference, not sure where is the mistake, the list appear 'undefined'.
Since i'm using the web api to return the data in json format that has been serialized, in controller i'm using below code
var jsonstring = responseGenderData.Content.ReadAsStringAsync();
lGender = JsonConvert.DeserializeObject<List<GenderEntity>>(jsonstring.Result);
ViewBag.datasourceGender = new SelectList(lGender, "JHGenderDesc", "JHGenderDesc");
in view, i try to use the sample code that has been shared
$('#JHGenderDesc').ejDropDownList(
{
dataSource: @Html.Raw(Json.Serialize(@ViewBag.datasourceGender)),
fields:
{
text: "JHGenderDesc",
value: "JHGenderDesc"
},
watermarkText: "Select Gender"
}
);
the count of the data appear, but it's show undefined
refer attachment for your reference
public IConfigurationRoot Configuration { get; }
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
// Add framework services.
services.AddMvc().AddJsonOptions(x =>
{
x.SerializerSettings.ContractResolver = null;
});
}
|
Thanks Keerthana
It's resolve my problem.