show row in column.
show row in column.
I have a html table and bind data using datatable. In this table I have only one column means only one <td> in a <tr>.
I want to show this 5 <tr> in one row and in next row it will show next five <tr> and then continue like that. also I need default search and pagination of the jQuery datatable remain same.
<tr class="profile-box odd" role="row">
<td>
<img class="user-icon" src="/images/user-img.jpg">
<h3>Pratik Singh</h3>
<h4>pratik.singh@gmail.com</h4>
<p>9876543210</p>
<span class="green">Active</span>
<div class="btn-wrap">
<a class="edit-btn" href="#"><img src="/images/edit_black.svg"> Edit</a>
<a class="view-btn" href="#"><img src="/images/edit_black.svg"> View</a>
</div>
</td>
</tr>
Answers
You will need to wrap the row in a -tag table` tag, like this:
http://live.datatables.net/vidicufe/1/edit
Otherwise it will look like two rows in HTML not a table within a cell.
Kevin
Hi kthorngren I check your code its run fine but the issue is when I Search something it will show the all row result. I just modified your code. Please check the link
live.datatables.net/vidicufe/4/edit
Now if you search "Gaurav Sen" it will show two result. But I need only "Gaurav Sen" in the result. Please help me.
My basic requirement is, I have a data like this
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
But I have to show like this in 1st page
1 2 3 4 5
6 7 8 9 10
in 2nd page
11 12 13 14 15
16 17 18 19 20
and if I search "13" then it will show only one result.
As I said before you need to use the
table
tag to separate the rows. Notice in your example the info element hasShowing 1 to 2 of 3 entries
. Inspect the HTM and you will see that the two rows are in onetr
:Like this:
http://live.datatables.net/fiqogela/1/edit
Now the info element shows
Showing 1 to 2 of 4 entries
.Its an HTMl structure issue, not a Datatables issue. This is your example without Datatables.
http://live.datatables.net/vidicufe/5/edit
You will see that your two rows are combined into one row in HTML
Kevin
yes I saw you approach but it shows in row but my requirement is like that.
I have a data like this
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
But I have to show like this in 1st pagination
1 2 3 4 5
6 7 8 9 10
in 2nd pagination
11 12 13 14 15
16 17 18 19 20
and if I search "13" then it will show only one result.
To make sure I understand. You have 20 rows of source data that you want to restructure to show in four rows, two on each page. There is nothing in Datatables to do this for you. You will need to restructure your source data into the four rows before initializing Datatables with the data.
If you need help with this please update or provide a test case that shows an example of your source data.
Kevin