Hi not able to initialize the basic table
Hi not able to initialize the basic table
AbhijitB
Posts: 2Questions: 1Answers: 0
Hi ,
I am pretty new to the DataTables. just started, i have followed all the steps however not able to render the Table with default configuration. could please help.
i am using MVC 4 EF 6 on ASP.net
This discussion has been closed.
Answers
Are you getting any alert messages or errors in the browser's console?
Without seeing the issue its hard to say what the problem is. Can you post a link to your page?
Kevin
Hi thanks for response. i ma learning asp.net and i have website which is hosted on IIS express by VS IDE.
There are no errors or alerts the page is rendered in response to request however the table which is rendered do not come with Datatables default look and feel e.g. the no of records to display, pagination etc.
I am adding the** layout.page** content here for your review
(''')
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>@ViewBag.Title - MTO Estimator</title>
</head>
<body>
<div class="container">
<nav class="navbar navbar-expand-sm navbar-dark fixed-top bg-dark">
<div class="container">
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#mtoNavbar" aria-controls="mtoNavbar" aria-expanded="false" aria-label="Toggle navigation"><span class="navbar-toggler-icon"></span></button>
<a class="navbar-brand" href="#">MTO Estimator</a>
</body>
</html>
(''')
And my page which render table is reproduced below
@model IEnumerable<MtoEstimator.Entities.DIM_PROJECT>
@{
ViewBag.Title = "Index";
Layout = "~/Views/Shared/_Layout.cshtml";
var pageController = ViewContext.RouteData.Values["controller"].ToString();
//var tablename = ViewData.ModelMetadata.DataTypeName();
}
@*
Projects
@Html.ActionLink("Create New Project", "Create")
@Html.DisplayNameFor(model => model.projname)
@Html.DisplayNameFor(model => model.clientname)
@Html.DisplayNameFor(model => model.plantdesc)
@Html.DisplayNameFor(model => model.location)
@section scripts
$(document).ready(function () { $("#projTable").DataTable({ "paging": true, "ordering": true, "info": true }); }); $(function () { $("#projTable tr").click(function () { var tableData = $(this).children("td").map(function () { return $(this).text(); }).get(); alert("Your data is: " + $.trim(tableData[0]) + " , " + $.trim(tableData[1])); }); });{
}