Eswar Datta

Eswar Datta

  • 1.9k
  • 115
  • 3.3k

Jquery DataTable in MVc

Jun 21 2018 2:28 AM
Jquery Datatable in MVC
This is my controller Action
Controller Action
public ActionResult Retrieving()
var data= db.retrieve();
return Json(new { data = data },JsonRequestBehavior.AllowGet);
Iam trying to call this method using jquery datatable
This is my view page and i wrote jquery code and also placed jquery
ViewBag.Title = "RetrievingSwAssets";
Layout = "~/Views/Shared/_Admin.cshtml";
<table id="RetrievingSwAst">
datatable links
<link href="//"
rel="stylesheet" />
jquery datatable links
@section Scripts{
<script src="//"></script>
<script src=""></script>
<script src="~/Scripts/angular.min.js"></script>
$(document).ready(function () {
"ajax": {
"url": "/Admin/Retrieving",
"type": "GET",
"datatype": "json"
"columns": [
{ "data": "AssetID", "autoWidth": true },
{ "data": "AMSSW_AssetName", "autoWidth": true },
{ "data": "AMSSW_AssetType", "autoWidth": true },
{ "data": "AMSSW_Vendor", "autoWidth": true },
{ "data": "AMSSW_Version", "autoWidth": true },
{ "data": "Date_of_purchase", "autoWidth": true },
{ "data": "CompanyLocation", "autoWidth": true },
But Its Retrieving json format.
1","AMSSW_AssetName":null,"AMSSW_AssetType":"Software Asset","AMSSW_Vendor":null,"AMSSW_Version":null,"Date_of_purchase":null,"CompanyLocation":null},{"AssetID":"SW-Asset-2","AMSSW_AssetName":null,"AMSSW_AssetType":"Software Asset","AMSSW_Vendor":null,"AMSSW_Version":null,"Date_of_purchase":null,"CompanyLocation":null},{"AssetID":"SW-Asset-3","AMSSW_AssetName":"VisualStudio 2017","AMSSW_AssetType":"Software Asset","AMSSW_Vendor":"Micrsoft","AMSSW_Version":"15.2","Date_of_purchase":"2018-06-13","CompanyLocation":"hyd"}]}
I want to display this data in Table format
I don't no where the mistake. Plz solve it...

Brought to you by:

Answers (2)