Set custom number of total records/ Count records using rows having specific class
Set custom number of total records/ Count records using rows having specific class
Hi,
The problem is that i have some rows in my table which do not need to be counted in number of records, but i think as datatables works record count as number of rows in <tbody> so it makes the records count faulty for me. I need some way to set the number of records so that everything (sorting, filtering, paging, number of records shown in "bInfo") else works fine but use my custom specified number of total records.
Is there any way to set the total number of records or any was to tell datatables to count only those rows which have a certain class specified and do not count other rows in the <tbody> of that table. For example see following rows:
<tbody>
<tr class="dataRowForCount"><td>Data 1</td></tr>
<tr class=""><td>---</td></tr>
</tbody>
Now the datatables needs to show "1 of 1 record showing" instead of "1 of 2 records showing", i have made the example on Data Tables Live which contain some rows with class "dataRowForCount" now i need datatables to just have them as number of records and other filters working on them. Please help.
Answers
Hello haseeb293,
I'm not sure what you're trying to do. If the table has five rows then that is what a user should see so you don't confuse them.
However, if you what to give them additional information, such as there are three rows that are special, you might want to try:
Then you just display the counter information.
Hope this helps.
zeinerrj, the thing is that there are some rows with no data in them and rows which i do not want to get added in the counter. The text you see "showing 1 of N records" and on filtering "showing 1 of N records" this must be calculating all of the rows inside the <tbody> tag. But i want my N to be equal to what i specify this can be a static number or count of rows which has a class named "dataRows".
Is there any option or setting which could simply set the number of records?
The following table has 5 rows, now the usual setup of datatables will show total records as 5 and if you will search for 20 it will show two records filtered out of 5 records. Now what i need is to count the rows with class "dataRow" and set is as the total records in the table in datatables setup so that it may show "Showing 1 to 3 of 3 entries" NOT "Showing 1 to 3 of 5 entries"and on filtering "20" it shows "Showing 1 to 2 of 2 entries (filtered from 3 total entries)" NOT "Showing 1 to 2 of 2 entries (filtered from 5 total entries)"
I have also added this to the DataTables live here is the link: http://live.datatables.net/vafejoni/1/.
Hi, I'd like to know this, too, since it would be useful when the data is retrieved by an external service that already pages the result. So I can show the total number of results instead of the page length the service is using.
Is there a way to update the total number of records on a dataTable without altering the data itself?