如何解决ASP.NET MVC下拉列表在移动视图上无法正常运行
我正在从事MVC 5 Web应用程序项目。我在cshtml页面中创建一个字段(下拉列表字段),并在某个提供程序的控件中使用它(Syncfusion)。该应用程序在桌面视图上运行良好(它具有数据,该数据是从控制器通过模型传递的字符串列表)。但是,当我切换到移动视图时,dropdownlist字段显示为null。
我将共享我在cshtml页面中添加字段的代码。
//在初始时间创建所需的自定义元素
if (!args.element.querySelector('.custom-field-row')) {
//Creating an element on the base of EJ inside a div and append it to class custom-field-row
var row = ej.base.createElement('div',{ className: 'custom-field-row' });
//putting the schedule object in a variable called formElement
var formElement = args.element.querySelector('.e-schedule-form');
//Inserting the creating elemenet at a certain location on the Popup Event
formElement.firstChild.insertBefore(row,args.element.querySelector('.e-title-location-row'));
//Creating an element in a div with joining it to class called custom-field-container
var container = ej.base.createElement('div',{ className: 'custom-field-container' });
//Create input element with class name e-field e-event-type and setting attribute name to EventType
var inputEle = ej.base.createElement('input',{
className: 'e-field e-event-type',attrs: { name: 'EventType' }
});
// var costEle = ej.base.createElement('input',{ className: 'e-field e-cost-type',attrs: { name: 'Cost' } });
//Appending the created input element to the container which is the element created under class name custom-field-container
container.appendChild(inputEle);
//container.appendChild(costEle);
//Appending the container created to the row
row.appendChild(container);
//Creating an array to assign to datasource
var myArray = [];
@foreach (var service in Model.ServicesArray)
{
@*@:myArray.push("{ text: '@service.text',value: '@service.value' }");*@
@:myArray.push("@service.text");
}
//Creating the drop down list datasource
var drowDownList = new ej.dropdowns.DropDownList({
dataSource:
myArray,fields: { text: 'text',value: 'value' },value: (args.data).EventType,floatLabelType: 'Always',placeholder: 'Service'
});
//Appending the drop down list to the created input element
drowDownList.appendTo(inputEle);
//setting created input element namee
inputEle.setAttribute('name','EventType');
}
提前感谢您的所有努力。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。