Link to home
Start Free TrialLog in
Avatar of Moti Mashiah
Moti MashiahFlag for Canada

asked on

Json and asp.net mvc

Hi Guys,

I'm returning json to the view:

Here is my controller method:
public JsonResult Returnjson()
        {
            RMSmasterDBtestEntities db = new RMSmasterDBtestEntities();
            var q = db.Items.Select(a => new Class1
            {
                Itemlookupcod = a.ItemLookupCode,
                Description = a.Description
            }).Take(10).ToList();


            return Json(q, JsonRequestBehavior.AllowGet);
        }

Open in new window

This is my script:
 $(document).ready(function () {
            var dt = $('#example').DataTable({
                "processing": true,
                "serverSide": true,
                "ajax": ("Returnjson"),
                "columns": [
                    {
                        "class": "details-control",
                        "orderable": false,
                        "data": null,
                        "defaultContent": ""
                    },
                    { "data": "Itemlookup" },
                    { "data": "Description" }
                ],
                "order": [[1, 'asc']]
            });

Open in new window


What I would like to do it to return my data with the attribute data.

like before the params I need to have data: please look the example below:
{ "data": [{"name_en":"hello","phone":"55555555","email":"a.shouman","facebook":"https:\/\/www.facebook.com"},...] }
ASKER CERTIFIED SOLUTION
Avatar of Gautham Janardhan
Gautham Janardhan

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Moti Mashiah

ASKER

this solution solved my problem.