我正在尝试在视图中显示多组带有标题复选框的复选框,如下图所示。
从数据库我得到这样的数据,
CODE SUBCODE DESCR DESCR PrevOptIn
GLOBAL BOOKS Books Global products True
GLOBAL ENERGY4ME Energy Global products True
GLOBAL JOURNALS Journals Global products True
REGION ASIA_PACIFIC Asia Pacific Geographical False
REGION CANADA Canada Geographical True
REGION EUROPE Europe Geographical True
SPECIAL SALES Promotional Notices False
REGIONAL PROGRAMS Conferences Events False
REGIONAL COURSES Training courses Events False
REGIONAL EVENTS Web events Events True
当我单击该标题组复选框下方的标题复选框时,应选中/取消选中。
控制器
public ActionResult Index(string cusId = null,
string emailId = null, string marketoId=null )
{
_custCommPref.CustomerId = cusId;
_custCommPref.MarketId = marketId;
_lstOptInInterest = new LinkedList<OptInInterestArea>
((from a in _dbEntitiesA.APP_SUBCODE.Where(x => x.TYPE == "OPT_IN" &&
x.ACTIVE_FLAG == "Y")
join appCode in _personifyEntities.APP_CODE
on new { CODE = a.CODE, TYPE = a.TYPE } equals new {
CODE = appCode.CODE, TYPE = appCode.TYPE }
select new OptInInterestArea()
{
Code = a.CODE,
SubCode = a.SUBCODE,
SubCodeDescription = a.DESCR,
CodeDescription = appCode.DESCR
}).ToList());
_lstOptInInterest = new LinkedList<OptInInterestArea>
(
(from a in _lstOptInInterest
join b in _dbEntitiesB.CustCommPreferences
on new { CODE = a.Code, SUBCODE = a.SubCode } equals new {
CODE = b.Code, SUBCODE = b.Subcode }
into leftGroup
from b in leftGroup.DefaultIfEmpty()
select new OptInInterestArea()
{
Code = a.Code,
SubCode = a.SubCode,
SubCodeDescription = a.SubCodeDescription,
CodeDescription = a.CodeDescription,
PrevOptIn = b != null && b.OptedIn == true
}).ToList()
);
_custCommPref.OptInInterestAreas =
new List<OptInInterestArea>(_lstOptInInterest);
return View(_custCommPref);
}
我在这里停下来创造更远的视野。请建议我。