How to use Datatables with no headers
How to use Datatables with no headers
vlince
Posts: 10Questions: 0Answers: 0
Hello all,
Building a C# asp.net mvc 4.0 project and I have this object:
[code]
public class CompanyReview
{
public int Id { get; set; }
public string Name { get; set; }
public string AvatarLink { get; set; }
public int Ranked { get; set; }
public double OverallCompanyScore { get; set; }
public CompanyScoreDetail CompanyScoreDetail { get; set; }
public IEnumerable Reviews { get; set; }
public int TotalReviews { get; set; }
}
[/code]
At some point, I’ve manage to create/have a collection of CompanyReview (aka: IEnumerable).
I’d like to display the data inside a fashion but without having to define any headers (aka: aoColumnDefs)
Is this even possible or does a minimum of one aoColumnDefs must be defined but visible to false?
As of this writing, I’m getting the following error:
[quote]DataTables warning (table id = 'example'): Requested unknown parameter '0' from the data source for row 0[/quote]
According to the many posts I’ve read, it appears to be related with the fact that I have no columns defined (which is precisely what I want).
Here is my HTML:
[code]
[/code]
If I try removing the I’m getting another error: “k is undefined” so it appears that a is mandatory…
If you need more code, I’ll gladly post, just let me know.
Thanks
Building a C# asp.net mvc 4.0 project and I have this object:
[code]
public class CompanyReview
{
public int Id { get; set; }
public string Name { get; set; }
public string AvatarLink { get; set; }
public int Ranked { get; set; }
public double OverallCompanyScore { get; set; }
public CompanyScoreDetail CompanyScoreDetail { get; set; }
public IEnumerable Reviews { get; set; }
public int TotalReviews { get; set; }
}
[/code]
At some point, I’ve manage to create/have a collection of CompanyReview (aka: IEnumerable).
I’d like to display the data inside a fashion but without having to define any headers (aka: aoColumnDefs)
Is this even possible or does a minimum of one aoColumnDefs must be defined but visible to false?
As of this writing, I’m getting the following error:
[quote]DataTables warning (table id = 'example'): Requested unknown parameter '0' from the data source for row 0[/quote]
According to the many posts I’ve read, it appears to be related with the fact that I have no columns defined (which is precisely what I want).
Here is my HTML:
[code]
[/code]
If I try removing the I’m getting another error: “k is undefined” so it appears that a is mandatory…
If you need more code, I’ll gladly post, just let me know.
Thanks
This discussion has been closed.
Replies
That is the case yes. http://datatables.net/usage/#prerequisites .
One option, if you can't alter the server to output the required markup, is to use a line or two of jQuery to pull out the first row in your table, create a THEAD element and insert the row, before initialising DataTables.
Allan
Id
Name
...
..
.