How i can use list inside a list in DataTables.

How i can use list inside a list in DataTables.

PropwisePropwise Posts: 4Questions: 1Answers: 0

I am having a list that each list item contain another list. On the time of render the column it will give me error "http://datatables.net/tn/7". I look a lot but not found any solution. Please help me to overcome by this issue.

Thanks

Answers

  • tangerinetangerine Posts: 1,922Questions: 9Answers: 213

    So after you followed the Diagnostic steps at the /tn/7 link, what is your server error?

  • PropwisePropwise Posts: 4Questions: 1Answers: 0

    I am facing 500 Internal Server error .
    Full Error is below
    A circular reference was detected while serializing an object of type 'System.Data.Entity.DynamicProxies.tblPropertyDocument_C39281F23DAA0C224A777580A8038E1E55D91AF3EBEC9D53EF39EC1E6EAAAD0C'.

  • kthorngrenkthorngren Posts: 1,668Questions: 18Answers: 352

    I'm not sure where your problem is but a google search of

    A circular reference was detected while serializing an object of type

    brings up many results. Maybe one of those will help. Otherwise post your server side code for additional help.

    Kevin

  • allanallan Posts: 43,525Questions: 1Answers: 5,695 Site admin

    JSON can't represent a circular structure. You'd need to parse it into a List which is not circular.

    Allan

  • PropwisePropwise Posts: 4Questions: 1Answers: 0
    edited July 17

    Actually I have a list of objects and inside each object i have another list. When i will return data to the datatable it will generate the circular error due for the inner list items. I know why this problem occur but not get how to resolve it.
    Below is my code:
    var SelectedAllSending = AllSending1.Select(s => new OutgoingCommunicationVM()
    {
    dDate = s.dDate,
    id = s.id,
    cDescription = s.tblDDLSelect.cDescription,
    cSubject = s.cSubject,
    Recipients = (from t in db.tblRecipients where (t.nMessageID == s.id) orderby t.cName select t).Take(3).ToList(),
    TotalRecords = totalRecords,
    PageCount = GetPageCountUSPS(s.id, s.tblDDLSelect.cDescription),
    EstimatedCost = GetCost(s.id, s.tblDDLSelect.cDescription)
    }).ToList();

    as you see in my code I have a list "SelectedAllSending" and inside this list I have another list by the name off "Recipients".

    When i will return value to the datatable it will give me error. Below is my code.

    return Json(new { draw = draw, recordsFiltered = recordsTotal, recordsTotal = recordsTotal, data = SelectedAllSending }, JsonRequestBehavior.AllowGet);

    object inside object gives circular error on json return. Or how i can pass list inside list in datatable.
    please help me to overcome this issue.

  • PropwisePropwise Posts: 4Questions: 1Answers: 0
    edited July 17

    ,

  • tangerinetangerine Posts: 1,922Questions: 9Answers: 213

    Allan gave you the solution: parse your data into an acceptable format.

  • allanallan Posts: 43,525Questions: 1Answers: 5,695 Site admin

    The inner list elements must refer to the outer elements, or perhaps to itself. You'd really need to ask in StackOverflow or similar for C# programming help I'm afraid.

    Allan

Sign In or Register to comment.