BootStrap Datatable not loading in Modal popup
BootStrap Datatable not loading in Modal popup
I have a requirement to populate a Datatable in Modal on click button event . The modal empty every time. Please advise how to load the datatable. Below is the code of the datatable initialisation.
var table = $('#example1').DataTable( {
"processing": true,
"serverSide": true,
ajax: {
url: 'details/Details5.json',
dataSrc: "data"
},
columns: [
//data : response,
{ "data": "ProcessName" },
{ "data": "SubprocessCount" },
{ "data": "TotalActivityCount" },
{ "data": "MigrationEfforts" },
{ "data": "MapperCount" },
{ "data": "SOAPCall" },
{ "data": "RESTCalls" },
{ "data": "ProcessComplexity" }
Answers
Without seeing the page it would be impossible to guess what the problem might be. Please post a link to your page or a test case replicating the issue.
https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case
To troubleshoot you can start with these steps:
Let us know what you find.
Kevin
Hello kthorngren ,
Thanks for a quick response. My flow is as follows. on clikc
when details button is clicked a URL is called and the response is shown in the modal window. what are the additional processing steps needed apart from initializing the data table?
How are you fetching the data? How are you displaying the data. Are you using the above Datatables code to display the modal or is that for the original table?
That depends on how you are doing the above. This set of examples shows different ways to initialize Datatables for different data sources. More information can be found in the Data docs.
Please provide more specifics of how you showing the data in the modal. Code snippets would be good. Or provide a test case so we can see what you have. Then we can provide more specific answers.
Kevin
Hello,
when the details button is clicked we send the first column value to the back end to get more details. The details may go up to 100 rows. The response recieved is saved as a json file
below is the code snippet
what additional steps needed to bind the datatable to the modal-body?
Edited by Kevin: Syntax highlighting. Details on how to highlight code using markdown can be found in this guide
Does the modal body have a
table
with the IDexample1
?Is this fetching the detail rows?
Does
data
have the detail rows?What is this fetching?
What are you trying to do with this code?
What I would do is use
to fetch and return the detail rows. Then use
data
to add the data to the Datatable and remove theajax
option.If you still have problems the please explain exactly what happens:
details.php?name='+firstCellText
URL?details/Details8.json
URL?If you are unable to provide a link showing the problem then you will need to follow the steps your code takes to determine where the problem is. Unfortunately there are still a lot of questions that we don't know in order to help. Let us know what you find and maybe we can provide some guidance.
Kevin
I am have uploaded the Modal window snapshot No table in it. No significant errors in the browser console
$('#example1').DataTable().ajax.reload();
What is returned by the details.php?name='+firstCellText URL?
What is returned by the details/Details8.json URL?
We're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. 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
The screenshot helps to understand the actual problem. Based on that screenshot it looks like you have the
table
tag hidden. Since the Datatable info is showingShowing 1 to 2 of 2 entries
that means your process is working. There is omething in the HTML of the modal thats not correct. If you are unable to solve it then, as Colin said, we will need a test case to help debug.Kevin
Hi Kevin,
the issue is resolved. show() was not added. Thanks for all the help