0

I need to display the data returned from my controller class of type JSON in HTML table on View.

Below are the details.

Controller class

 ROCRespository rocrep = new ROCRespository();
    public JsonResult ROC() 
    {
        return Json(rocrep.GetAllRocDetails(),JsonRequestBehavior.AllowGet);
    }

Model Class:

 public class ROCRespository 
{
    public List<ROC> roc;
    public ROCRespository() 
    {
        this.roc = new List<ROC>() 
        {
            new ROC(){CourseId="1",CourseName="Softskill 321 : Client Interaction through conference call",CourseImagePath="../../Content/Images/php.png"},


        };
    }
    public List<ROC> GetAllRocDetails() 
    {
        return roc;
    }
}

I need to display the details in my view as HTML table.

Edit:

Currently I am getting an output like,

[{"CourseId":"1","CourseName":"Softskill 321 : Client Interaction through conference call","CourseImagePath":"../../Content/Images/php.png","rating":0}]

Need to display in a neatly designed table or div's

Sankar Sai
  • 57
  • 6
  • I can suggest that you google `Grid.MVC` but without telling us what you plan to use this question is too broad. – Inspector Squirrel Aug 06 '15 at 15:07
  • Hi, I need to design a part of a website where learning details will be displayed. I don't want use Grid..My query is very simple, How to display the Model details which is sent as JSON object by controller, in HTML format..That's it.. – Sankar Sai Aug 07 '15 at 13:28
  • This was a different question 23 hours ago. – Inspector Squirrel Aug 07 '15 at 14:19

1 Answers1

0

You can use Jquery datatables that accepts the JSON as datasource. See this sample which uses the Json source to create a HTML table with extended grid functionalities.

Or

You can build your custom HTML from JsonResult like this and this.

Community
  • 1
  • 1
vendettamit
  • 14,315
  • 2
  • 32
  • 54