DataTables Tabs
DataTables Tabs
Hi Allan,
Not sure if you could help.
I got three div elements .well class
<div class="container">
<div class='well'><p>Grid 1<./p></div>
<div class='well'><p>Grid 1<./p></div>
<div class='well'><p>Grid 1<./p></div>
</div>
Got Jquery function workingclick('.well')
working fine and trapping alert. So far so good.
click('.well') alert
is responding. Now i got three tabs underneath Tab1 TAb2 Tab3 I
would like to open a respective datatable grid underneath when clicks the following:
<div class='well'><p>Grid 1<./p></div>
<div class='well'><p>Grid 1<./p></div>
<div class='well'><p>Grid 1<./p></div>
Please note all the grids 1,2,3 are using different tables, ie., grid 1 is using employee table, grid 2 is using customer table and grid 3 is using order table.
Any help is highly appreciated.
Many thanks for your help in advance.
This question has an accepted answers - jump to answer
Answers
I manage to get to this but i need to use jquery. plese can someone help.
Hi @SalmanS ,
This thread here discusses putting different tables into their own tabs - it'll be worth taking a look. There's a working example at the bottom of the page.
If that doesn't help, would you be able to create a running example of your code? It would help to debug it. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.
Cheers,
Colin
Many thanks colin for your answer, you are a champion. I was struggling so much to get this working over weeks.
The example is great.
Is there a way I can call data using
emp_tab.php
file by addingurl: emp_tab.php
===jquery script to pull data from server side using php=============
=============Code from live Example===================
=============
I am just wondering how I could use php for server side processing and replace this code.
I am still struggling.
here is my code:
Please help.
To me its unclear what exactly is the issue. Maybe you can describe more about the issue and alert errors or errors in your browsers console you are getting.
However I do see one thing. You are defining three columns in your Datatables init code but have six defined in your table. You will get errors because of this.
Kevin
Hi Kevin,
I just want three taps and onclick build the datagrid for the respective section.
My Bootstrap Tabs are working fine.
Here is my bootstrap code: I tried so many methods earlier to build grids within those tabs and none is working.
Here is my basic Bootstrap Tabs. please help how i can pull data from php or text file using DATATABLE
Hi Kevin,
I just want three taps and onclick build the datagrid for the respective section.
My Bootstrap Tabs are working fine.
Here is my bootstrap code: I tried so many methods earlier to build grids within those tabs and none is working.
Here is my basic Bootstrap Tabs. please help how i can pull data from php or text file using DATATABLE
Hi @SalmanS ,
There's two immediate things that look wrong,
example3-tab2-dt
, but when you initialise the table, you're passing in IDs like this,tab3
, so DataTables wouldn't be able to find that table. Those IDs need to matchI'd say get those two things sorted and them either create a test page, or link to the page so we can take a look if there's still problems.
Cheers,
Colin
Hi Colin,
Sorry my bad. many thanks for getting back to me. I changed the code and not sure if this is the best way, how I have to use DATATABLES or maybe there is better way? God knows.
Anyway, as stated earlier with my bootstrap tabs. Just want to achieve display data in three tabs by calling from ajax request with pagination.
Here is my boostrap tabs code and underneath is my original code with respective columns:
ORIGINAL CODE with respective columns:
I found another example at jquery. but i am sure we can achieve all this using DATATABLES. How do i pull data in the respective tabs.
I haven't dug through your code. If you want help with your code then please provide a test case so we can help you debug.
Here is an example with Bootstrap tabs. The first tab uses table data from the DOM, the second uses ajax with objects and the third uses ajax with arrays.
http://live.datatables.net/xojiqite/1/edit
Kevin
As Kevin said, it would really help if you could demonstrate this problem. We're circling around here, and seeing it running would help to resolve those silly issues - for example the wrong IDs and the wrong column widths.
In my first post, there's a link to another thread which contains several fiddles to pages with tabs - this really helped people to get a feel for what was required. If you could look at that page, create a similar fiddle for your environment (we don't need real data, that can be mocked), then we can get to the bottom of this much quicker.
Cheers,
Colin
Million and billion thanks to kevin for providing the sample code. I was earlier. Kevin God bless you man for you help.
You help is great, unlike others who start critcizing and makes you cry. we come on this platform for help because we dont know.
@colin i dont know how to create fiddle, but Kevin's sample is great. Love you kevin for your help.
I owe you.
Kevin if you dont mind, i would like to clarify the following:
Input is text and set the
id=global_filter
. It looks like a majic and the tabs are responding for the respective tab and data displayed. How does this happened.I understood the javascript function very well -
But i am unable to figure out, when we click the
<li><a href="#2" data-toggle="tab">Table 2</a>
tabs, its calling the above function how?Any thoughts or explanation is highly appreciated.
Bless you.
The above code was to show someone else how to run a search that searched all tables. Clicking the tab is not running that code. Its the text input you see above the tabs.
Removed that search input to make it less confusing.
http://live.datatables.net/bemofozu/1/edit
Kevin
Kevin, you are the king. a scripting guru.
so elegant, so simple, i cannot thank you enough for your help.
if i understood it clearly my small brain, its building all the grids when document is ready. is there a way we can call build/fill each tab grid, when the tab is clicked?.
I want to make it scrolly records 200 at a time.
I googled for over 1 week and i saw hundreds of scripts but non matched kevin's simple technique. Tabs and DATATABLE grids.
All the other scripts on google were talking about redraw, column size and so lenghty and confused posts.
Kevin's code is so simple.
You will use the Bootstrap
shown.bs.tab
event. Take a look here for the docs:https://www.w3schools.com/bootstrap/bootstrap_ref_js_tab.asp
In the event function you can init the Datatable in the tab.
According to the
scrollY
docs you give it a number or a CSS unit. It doesn't have an option for specific number of rows. You will need to adjust the number to show the number of rows you want.Kevin
Sorry kevin i being a daft.
This is my modified code:
when the document is ready i am calling the ``.click event
?
am i doing o.k.You can update my examples and post the link to them if you have questions. That would be a good way to help.
I meant for you to looks at the Tab Events section of this doc and see the example for
shown.bs.tab
:https://www.w3schools.com/bootstrap/bootstrap_ref_js_tab.asp
You have this but my example doesn't have anything with the id of
3
. Also if you wanted to use the an id selector you would use"#3"
.Here is an updated example using the tab event:
http://live.datatables.net/zuyozuxu/1/edit
Notice I added
destroy: true,
to the tables in tabs 2 and 3. This is so the tables can be reloaded without errors. See thedestroy
doc for more info.I put a console.log statement in so you can see what the value of
$(event.target).text()
from the w3schools example. If you monitor the Network Tab of your browser's developer tools you can see the tab 2 and tab 3 tables aren't loaded until you go to the tab.Kevin
Many thanks kevin, I dont know how to update your links or create a new on on liv.datatables.net.
Are we allowed to modify the code or create a new one.
http://live.datatables.net/zuyozuxu/1/edit
You can use the
clone
option to create a copy:You can create a new one using the steps here:
https://datatables.net/manual/tech-notes/9
Kevin
This is the best support you could every get in this world.
longlive datatables
Thank you all. Specially my favorate The King Kevin. The Lion of Datatables. The scripting guru. there is not enough words i got to describe the champion Kevin.