Does standard vanilla jquery tables work with asp.net core?
Does standard vanilla jquery tables work with asp.net core?
lvsund
Posts: 7Questions: 2Answers: 0
On the opening web page for your site, it says to add the reference links and the additional javascript for datatables. When I do that it renders the grid in terms of the colors , headings etc and alternate row shading. But does not show the search box, the dropdown for record numbers to display, or the pagination.
Havent nugetted anything- just using CDN references per instructions on jquery datables site-opening page.
Am I missing something?
This discussion has been closed.
Answers
sounds like it. We need to see your code to see what is missing. ASP.Net core generated/renders code and html server side and sends it to the client. Jquery is a client side library so it just does not care if the page is rendered from aspx or html.
Now having said that, if you are generating tables on the server side, by default, thead and tfoot are not generated so you may need to take steps to ensure that is happening. There are examples of that on Stackoverflow
here is my code- tables/grid gets rendered - but no search box rows to display or paging:
@model IEnumerable<ServeMeHRCore21.Models.ServiceRequests>
@{
ViewData["Title"] = "Index";
}
Service Requests
Create New
@using (Html.BeginForm())
{
}
Service Requests
Sorry will try again with triple back ticks:
That looks like it should work okay. Could you run the debugger on your page if you can't give us a link to the page please?
Allan
still trying to figure out how to use datatables debugger, but when i just F12 the page in my broqwser, i get Uncaught ReferenceError: jQuery is not defined
at jquery.dataTables.min.js:5
Unless you are using a module builder such as WebPack, all you should need to do is copy the code from the debugger page, paste it into the console, hit return and away it goes.
Allan
that has usually been my experience, but the last few even fresh .net core apps i have created, doing the step mentioned on your site , displays the grid and colored heading bar, but just lists the records -no drop records to display, no search, and no pagination.
It does have something to do with above error. Another app i have same code and everything works- when i F12 no error message occurs and every displays as is should
I copied over an equivalent cshtml from a version where it was working into current application and then it started working again- obviously something wrong with cshtml page. thanks
It might be the load order of the Javascript then, or perhaps jQuery being loaded twice.
Either way, good to hear you have it working now.
Allan