DataTable jQuery plug-in dynamic table creation and data
DataTable jQuery plug-in dynamic table creation and data
KenAdeniji
Posts: 1Questions: 1Answers: 0
var isPostBack = false;
var dataSet = null;
function dataParse()
{
document.getElementById("resultSet").innerHTML = "";
sqlStatements =
[
`SELECT * FROM ? WHERE chapterIdSequence = 22`,
`SELECT * FROM ? WHERE bookId = 43 AND chapterId = 1`
];
for
(
var sqlStatementId = 0,
sqlStatementIdCount = sqlStatements.length;
sqlStatementId < sqlStatementIdCount;
++sqlStatementId
)
{
var alasResult = alasql
(
sqlStatements[sqlStatementId], [dataSet]
);
var resultTable = document.createElement("table");
resultTable.id = "resultTable" + sqlStatementId;
let myTable = $('#' + resultTable.id).DataTable
(
{
"data": alasResult,
"columns": [
{ "data": "verseIdSequence" },
{ "data": "scriptureReference" },
{ "data": "KingJamesVersion" }
],
destroy: true
}
);
//document.getElementById("resultSet").appendChild(myTable);
$("#resultSet").append(myTable);
//scriptLiteral9432.renderDataTable(alasResult, "resultSet")
}
}
function querySubmit()
{
if (dataSet) { dataParse(); return; }
var request = {};
//request["scriptureReference"] = scriptureReference;
var requestJson = JSON.stringify(request);
$.ajax
({
type: "POST",
contentType: "application/json; charset=utf-8",
url:
"/WordEngineering//AlaSQL.js/AlaSQL.js_-_OnlyRefuseSubstainTheLine.asmx/Query",
data: requestJson,
dataType: "json",
success: function(data)
{
dataSet = JSON.parse(data.d);
dataParse();
},
error: function(xhr)
{
$("#resultSet").html
(
'Status: ' + xhr.status + " | " +
'StatusText: ' + xhr.statusText + " | " +
'ResponseText: ' + xhr.responseText
);
}
});
}
function pageLoad()
{
if (isPostBack === false)
{
$.getScript
(
"/WordEngineering/WordUnion/9432.js",
function( data, textStatus, jqxhr )
{
var scriptureReference =
scriptLiteral9432.getParameterByName
(
"scriptureReference"
);
if (scriptureReference)
{
document.getElementById
(
"scriptureReference"
).value = scriptureReference;
}
scriptLiteral9432.renderBibleVersionSelect();
var bibleVersion =
scriptLiteral9432.getParameterByName
(
"bibleVersion"
);
if (bibleVersion)
{
document.getElementById
(
"bibleVersion"
).value = bibleVersion;
}
querySubmit();
isPostBack = true;
});
}
else
{
querySubmit();
}
}
window.addEventListener("load", pageLoad, false);
document.getElementById
(
"submitQuery"
).addEventListener
(
"click",
querySubmit,
false
);
This discussion has been closed.
Answers
Hi @KenAdeniji ,
I'm not clear if you're sharing your code, or whether you want help with it. If there is a problem, we're happy to take a look, but it would help, as per the forum rules, if you could link to a running test case showing the issue so we can offer some help. 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