fnCallback displaying only first letter of response in datatables
I am fetching data tables data from ElasticSearch index as follows. When I want to render the data into Datatable only first letter of the result
in fnCallback method is populating. Am I missing anything here?
var oTable = $('#titleTable').dataTable( {
"bProcessing": true,
"sDom" : '<"top"i>rt>',
"bSort": false,
"asStripeClasses": ,
"sAjaxSource": "http://localhost:9200/data_index/_search?source_content_type=application/json&source={"query":{"match_all":{}}}}",
"fnServerParams": function ( aoData ) {
aoData.push(
{ "name": "title_search", "value": $('#title_search').val()}
);
},
"fnServerData": function (sSource, aoData, fnCallback){
var sEcho=aoData[0].value;
query = '{"query":{"match_all":{}}}';
$.ajax({
"type": "GET",
"url": sSource,
"success": function(response) {
var result = new Object();
result["sEcho"] = sEcho;
result["iTotalRecords"] = response.hits.total;
result["iTotalDisplayRecords"] = response.hits.total;
var arr = ["<table style="width: 100%;"><tbody><tr>"];
response['hits']['hits'].map(function(i){
arr.push("<td><table><tr><td><div class="title">" +
"<a href="report.php?a=CompanyDetail&id=853">" +
"<img src="images/company/12345.jpg"><br />"+i['_source']['company_title']+
"</a></div></td></tr><tr><td><div class="bookmark-title" onclick="return edit_company(853);">" +
"<span id="editcompany_853">Edit Company</span></div></td></tr></table></td>");
});
arr.push("</tr></tbody></table>");
result["aaData"] = arr;
fnCallback(result);
},
error: function (xhr, textStatus, error){
}
});
}
});
Result JSON
{
"sEcho":1,
"iTotalRecords":11,
"iTotalDisplayRecords":11,
"aaData":[
"<table style="width: 100%;"><tbody><tr>",
"<td><table><tr><td><div class="title"><a href="assetMngt.php?a=Details&id=853">
<img src="images/titles/1234567.jpg"><br />TTC Developers</a></div></td></tr><tr><td><div class="edit-company" onclick="return edit-company(853);"><span id="editcompany_853">Edit Company</span></div></td></tr></table>"
]
}
elasticsearch datatable datatables
add a comment |
I am fetching data tables data from ElasticSearch index as follows. When I want to render the data into Datatable only first letter of the result
in fnCallback method is populating. Am I missing anything here?
var oTable = $('#titleTable').dataTable( {
"bProcessing": true,
"sDom" : '<"top"i>rt>',
"bSort": false,
"asStripeClasses": ,
"sAjaxSource": "http://localhost:9200/data_index/_search?source_content_type=application/json&source={"query":{"match_all":{}}}}",
"fnServerParams": function ( aoData ) {
aoData.push(
{ "name": "title_search", "value": $('#title_search').val()}
);
},
"fnServerData": function (sSource, aoData, fnCallback){
var sEcho=aoData[0].value;
query = '{"query":{"match_all":{}}}';
$.ajax({
"type": "GET",
"url": sSource,
"success": function(response) {
var result = new Object();
result["sEcho"] = sEcho;
result["iTotalRecords"] = response.hits.total;
result["iTotalDisplayRecords"] = response.hits.total;
var arr = ["<table style="width: 100%;"><tbody><tr>"];
response['hits']['hits'].map(function(i){
arr.push("<td><table><tr><td><div class="title">" +
"<a href="report.php?a=CompanyDetail&id=853">" +
"<img src="images/company/12345.jpg"><br />"+i['_source']['company_title']+
"</a></div></td></tr><tr><td><div class="bookmark-title" onclick="return edit_company(853);">" +
"<span id="editcompany_853">Edit Company</span></div></td></tr></table></td>");
});
arr.push("</tr></tbody></table>");
result["aaData"] = arr;
fnCallback(result);
},
error: function (xhr, textStatus, error){
}
});
}
});
Result JSON
{
"sEcho":1,
"iTotalRecords":11,
"iTotalDisplayRecords":11,
"aaData":[
"<table style="width: 100%;"><tbody><tr>",
"<td><table><tr><td><div class="title"><a href="assetMngt.php?a=Details&id=853">
<img src="images/titles/1234567.jpg"><br />TTC Developers</a></div></td></tr><tr><td><div class="edit-company" onclick="return edit-company(853);"><span id="editcompany_853">Edit Company</span></div></td></tr></table>"
]
}
elasticsearch datatable datatables
add a comment |
I am fetching data tables data from ElasticSearch index as follows. When I want to render the data into Datatable only first letter of the result
in fnCallback method is populating. Am I missing anything here?
var oTable = $('#titleTable').dataTable( {
"bProcessing": true,
"sDom" : '<"top"i>rt>',
"bSort": false,
"asStripeClasses": ,
"sAjaxSource": "http://localhost:9200/data_index/_search?source_content_type=application/json&source={"query":{"match_all":{}}}}",
"fnServerParams": function ( aoData ) {
aoData.push(
{ "name": "title_search", "value": $('#title_search').val()}
);
},
"fnServerData": function (sSource, aoData, fnCallback){
var sEcho=aoData[0].value;
query = '{"query":{"match_all":{}}}';
$.ajax({
"type": "GET",
"url": sSource,
"success": function(response) {
var result = new Object();
result["sEcho"] = sEcho;
result["iTotalRecords"] = response.hits.total;
result["iTotalDisplayRecords"] = response.hits.total;
var arr = ["<table style="width: 100%;"><tbody><tr>"];
response['hits']['hits'].map(function(i){
arr.push("<td><table><tr><td><div class="title">" +
"<a href="report.php?a=CompanyDetail&id=853">" +
"<img src="images/company/12345.jpg"><br />"+i['_source']['company_title']+
"</a></div></td></tr><tr><td><div class="bookmark-title" onclick="return edit_company(853);">" +
"<span id="editcompany_853">Edit Company</span></div></td></tr></table></td>");
});
arr.push("</tr></tbody></table>");
result["aaData"] = arr;
fnCallback(result);
},
error: function (xhr, textStatus, error){
}
});
}
});
Result JSON
{
"sEcho":1,
"iTotalRecords":11,
"iTotalDisplayRecords":11,
"aaData":[
"<table style="width: 100%;"><tbody><tr>",
"<td><table><tr><td><div class="title"><a href="assetMngt.php?a=Details&id=853">
<img src="images/titles/1234567.jpg"><br />TTC Developers</a></div></td></tr><tr><td><div class="edit-company" onclick="return edit-company(853);"><span id="editcompany_853">Edit Company</span></div></td></tr></table>"
]
}
elasticsearch datatable datatables
I am fetching data tables data from ElasticSearch index as follows. When I want to render the data into Datatable only first letter of the result
in fnCallback method is populating. Am I missing anything here?
var oTable = $('#titleTable').dataTable( {
"bProcessing": true,
"sDom" : '<"top"i>rt>',
"bSort": false,
"asStripeClasses": ,
"sAjaxSource": "http://localhost:9200/data_index/_search?source_content_type=application/json&source={"query":{"match_all":{}}}}",
"fnServerParams": function ( aoData ) {
aoData.push(
{ "name": "title_search", "value": $('#title_search').val()}
);
},
"fnServerData": function (sSource, aoData, fnCallback){
var sEcho=aoData[0].value;
query = '{"query":{"match_all":{}}}';
$.ajax({
"type": "GET",
"url": sSource,
"success": function(response) {
var result = new Object();
result["sEcho"] = sEcho;
result["iTotalRecords"] = response.hits.total;
result["iTotalDisplayRecords"] = response.hits.total;
var arr = ["<table style="width: 100%;"><tbody><tr>"];
response['hits']['hits'].map(function(i){
arr.push("<td><table><tr><td><div class="title">" +
"<a href="report.php?a=CompanyDetail&id=853">" +
"<img src="images/company/12345.jpg"><br />"+i['_source']['company_title']+
"</a></div></td></tr><tr><td><div class="bookmark-title" onclick="return edit_company(853);">" +
"<span id="editcompany_853">Edit Company</span></div></td></tr></table></td>");
});
arr.push("</tr></tbody></table>");
result["aaData"] = arr;
fnCallback(result);
},
error: function (xhr, textStatus, error){
}
});
}
});
Result JSON
{
"sEcho":1,
"iTotalRecords":11,
"iTotalDisplayRecords":11,
"aaData":[
"<table style="width: 100%;"><tbody><tr>",
"<td><table><tr><td><div class="title"><a href="assetMngt.php?a=Details&id=853">
<img src="images/titles/1234567.jpg"><br />TTC Developers</a></div></td></tr><tr><td><div class="edit-company" onclick="return edit-company(853);"><span id="editcompany_853">Edit Company</span></div></td></tr></table>"
]
}
var oTable = $('#titleTable').dataTable( {
"bProcessing": true,
"sDom" : '<"top"i>rt>',
"bSort": false,
"asStripeClasses": ,
"sAjaxSource": "http://localhost:9200/data_index/_search?source_content_type=application/json&source={"query":{"match_all":{}}}}",
"fnServerParams": function ( aoData ) {
aoData.push(
{ "name": "title_search", "value": $('#title_search').val()}
);
},
"fnServerData": function (sSource, aoData, fnCallback){
var sEcho=aoData[0].value;
query = '{"query":{"match_all":{}}}';
$.ajax({
"type": "GET",
"url": sSource,
"success": function(response) {
var result = new Object();
result["sEcho"] = sEcho;
result["iTotalRecords"] = response.hits.total;
result["iTotalDisplayRecords"] = response.hits.total;
var arr = ["<table style="width: 100%;"><tbody><tr>"];
response['hits']['hits'].map(function(i){
arr.push("<td><table><tr><td><div class="title">" +
"<a href="report.php?a=CompanyDetail&id=853">" +
"<img src="images/company/12345.jpg"><br />"+i['_source']['company_title']+
"</a></div></td></tr><tr><td><div class="bookmark-title" onclick="return edit_company(853);">" +
"<span id="editcompany_853">Edit Company</span></div></td></tr></table></td>");
});
arr.push("</tr></tbody></table>");
result["aaData"] = arr;
fnCallback(result);
},
error: function (xhr, textStatus, error){
}
});
}
});
var oTable = $('#titleTable').dataTable( {
"bProcessing": true,
"sDom" : '<"top"i>rt>',
"bSort": false,
"asStripeClasses": ,
"sAjaxSource": "http://localhost:9200/data_index/_search?source_content_type=application/json&source={"query":{"match_all":{}}}}",
"fnServerParams": function ( aoData ) {
aoData.push(
{ "name": "title_search", "value": $('#title_search').val()}
);
},
"fnServerData": function (sSource, aoData, fnCallback){
var sEcho=aoData[0].value;
query = '{"query":{"match_all":{}}}';
$.ajax({
"type": "GET",
"url": sSource,
"success": function(response) {
var result = new Object();
result["sEcho"] = sEcho;
result["iTotalRecords"] = response.hits.total;
result["iTotalDisplayRecords"] = response.hits.total;
var arr = ["<table style="width: 100%;"><tbody><tr>"];
response['hits']['hits'].map(function(i){
arr.push("<td><table><tr><td><div class="title">" +
"<a href="report.php?a=CompanyDetail&id=853">" +
"<img src="images/company/12345.jpg"><br />"+i['_source']['company_title']+
"</a></div></td></tr><tr><td><div class="bookmark-title" onclick="return edit_company(853);">" +
"<span id="editcompany_853">Edit Company</span></div></td></tr></table></td>");
});
arr.push("</tr></tbody></table>");
result["aaData"] = arr;
fnCallback(result);
},
error: function (xhr, textStatus, error){
}
});
}
});
{
"sEcho":1,
"iTotalRecords":11,
"iTotalDisplayRecords":11,
"aaData":[
"<table style="width: 100%;"><tbody><tr>",
"<td><table><tr><td><div class="title"><a href="assetMngt.php?a=Details&id=853">
<img src="images/titles/1234567.jpg"><br />TTC Developers</a></div></td></tr><tr><td><div class="edit-company" onclick="return edit-company(853);"><span id="editcompany_853">Edit Company</span></div></td></tr></table>"
]
}
{
"sEcho":1,
"iTotalRecords":11,
"iTotalDisplayRecords":11,
"aaData":[
"<table style="width: 100%;"><tbody><tr>",
"<td><table><tr><td><div class="title"><a href="assetMngt.php?a=Details&id=853">
<img src="images/titles/1234567.jpg"><br />TTC Developers</a></div></td></tr><tr><td><div class="edit-company" onclick="return edit-company(853);"><span id="editcompany_853">Edit Company</span></div></td></tr></table>"
]
}
elasticsearch datatable datatables
elasticsearch datatable datatables
edited Jan 3 at 11:45
Devika
asked Jan 3 at 11:36
DevikaDevika
123213
123213
add a comment |
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54021515%2ffncallback-displaying-only-first-letter-of-response-in-datatables%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54021515%2ffncallback-displaying-only-first-letter-of-response-in-datatables%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown