My table is not rendering when using the editor and I can't figure out why

My table is not rendering when using the editor and I can't figure out why

nitewulf50nitewulf50 Posts: 3Questions: 1Answers: 0

My HTML is simple:

    <div class="col-12 border p-3">
        <table id="myBookTable" class="table table-striped table-bordered" style="width:100%">

I mostly used the example for the .js from the Editor example here:

var dataTable;

$(document).ready(function () {

function loadDataTable() {
    dataTable = $('#myBookTable').DataTable({
        ajax: {
            url: "/api/book",
            type: "POST"
        columns: [
            { data: "" },
            { data: "" },
            { data: "book.isbn" }
        columnDefs: [{
            searchPanes: {
                show: true,
            targets: '_all',
        dom: 'Plfrtip',
        serverSide: true

and my ASP.NET Core Controller looks like this:

        public IActionResult GetBooks() {
            using (var db = new Database("sqlserver", _db.Database.GetConnectionString())) {
                var response = new Editor(db, "book")
                    .Field(new Field("")
                        .SearchPaneOptions(new SearchPaneOptions())
                    .Field(new Field("")
                    .SearchPaneOptions(new SearchPaneOptions())
                    .Field(new Field("book.isbn")
                             .SearchPaneOptions(new SearchPaneOptions())

                return Json(response);

Debugger code ( acotur
Error messages shown: None
Description of problem: I put a break point in my controller on "return Json(response)". The response is getting populated, my search panes have data, and my data object is full of gibberish book information from my generated test data. The problem is that nothing is displayed in my search panes or table on my web page. If I don't use the Editor API, I'm able to get the table to render. What am I doing wrong?


  • nitewulf50nitewulf50 Posts: 3Questions: 1Answers: 0

    It looks like the issue is in the controller. I used Postman to query the API and even though my response object is full of populated properties, it's not being converted properly to JSON. Postman shows that I'm getting back {} - nothing. :/

  • nitewulf50nitewulf50 Posts: 3Questions: 1Answers: 0

    Okey dokey. In case anyone else has a similar issue with getting Json back from ASP.NET Core. I ended up creating an anonymous type from the Editors response and returning that as Json. Now I have server side processing working with SearchPanes! I had to dig into the SearchPannes property and get the options. Not sure if it'll be necessary to go deeper into any of the other objects to serialize them properly. Also not sure why this step was necessary at all as far as I can tell I'm not doing anything crazy. It's a pretty vanilla EF code first ASP.NET Core project.

                    var returnObj = new {
                        searchPanes = new {
                        response.upload };
                    return Json(returnObj);
  • titechnotitechno Posts: 9Questions: 3Answers: 0

    Hi I had a similar issue if you only need it to display the data try:

    return  Json( new { data = });

    instead of your code it should be easier

Sign In or Register to comment.