gpt4 book ai didi

javascript - jqGrid 中的动态列和使用下拉列表

转载 作者:行者123 更新时间:2023-12-03 06:23:41 25 4
gpt4 key购买 nike

我有一个关于在 jqGrid 中使用下拉列表的问题。在我的环境中,我使用许可证 jqGrid 4.4.4 - jQuery Grid(版本 4.4.4)和 MVC 5。

在下面的代码中,我从 Controller 动态创建 ColNamesColModel。一切正常,除了我想显示下拉列表值的列。现在,下拉列表是空的。为什么是空的?

此外,这些值应该如何,例如{value:{'FE':'FedEx';'IN':'InTime';'TN':'TNT';'AR':'ARAMEX'}},从 Controller 中的方法?

model.CreateMeeting = false;
SecondOpinionFacade = new SecondOpinionFacade();
var meeting = SecondOpinionFacade.GetMeeting(id);
model.MeetingDay = meeting.StartDate.Date;
model.MeetingdID = meeting.SecondOpinionMeetingId;
model.FromTime = meeting.StartDate.ToString("HH:mm");
model.ToTime = meeting.EndDate.ToString("HH:mm");
model.NrofGroups = meeting.SecondOpinionGroup.Count;

var list = new[] { new { name = "SecondOpionUserId", index = "SecondOpionUserId", sorttype = "string", sortable=false, hidden = true, editable = true, edittype = "", editoptions= "", formatter = ""} }.ToList();

这里我尝试将数据放入下拉列表中,但它似乎不起作用,因为下拉列表显示为空。

list.Add(new { name = "Deltagare", index = "Deltagare", sorttype = "string", sortable = true, hidden = false, editable = true, edittype = "select", editoptions = "{value:{'FE':'FedEx';'IN':'InTime';'TN':'TNT';'AR':'ARAMEX'}}", formatter = "select" });
int counter = 1;
meeting.SecondOpinionGroup.OrderBy(x=> x.SecondOpinionGroupId).ForEach(x =>
{
list.Add(new {name = x.SecondOpinionGroupId.ToString(), index = "Grupp" + counter, sorttype = "string", sortable = false, hidden = false, editable = true, edittype = "checkbox", editoptions = "{ value: 'True:False' }", formatter = "checkbox" });
counter++;
});

var list2 = new[] { "SecondOpionUserId" }.ToList();
list2.Add("Deltagare");
for (int i = 1; i <=model.NrofGroups; i++)
{
list2.Add("Grupp"+i);
}

model.ColNames = JsonConvert.SerializeObject(list2);
model.ColModel = JsonConvert.SerializeObject(list);
return View(model);

最佳答案

您使用字符串作为editoption的值。这是不对的。 editoptions 的值应为object。尝试更换

editoptions = "{ value: 'True:False' }"

editoptions = "{value:{'FE':'FedEx';'IN':'InTime';'TN':'TNT';'AR':'ARAMEX'}}"

editoptions = new { value = "True:False" }

editoptions = new { value = "FE:FedEx;IN:InTime;TN:TNT;AR:ARAMEX" }

关于javascript - jqGrid 中的动态列和使用下拉列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38745721/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com