0
我有一個關於在jqGrid中使用下拉列表的問題。在我的環境中,我正在使用許可證jqGrid 4.4.4 - 帶有MVC 5的jQuery Grid(版本4.4.4)。動態列和在jqGrid中使用下拉列表
在我的代碼中,我從我的控制器動態創建ColNames
和ColModel
。除了我希望顯示下拉列的值的列之外,一切正常。現在,下拉列表是空的。爲什麼它是空的?
另外,值應該如何{value:{'FE':'FedEx';'IN':'InTime';'TN':'TNT';'AR':'ARAMEX'}}
,從控制器中的方法動態加載?
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);
謝謝!這解決了這個問題,當我將editoptions從一個字符串改爲一個對象時,出現了一個小問題。我必須將列表中的所有其他editoptions設置爲對象,否則我會遇到compiliation錯誤。但我只是將它們設置爲editoptions = new {value =「」} – user3197410