Classic ASP and datatables usage

Classic ASP and datatables usage

akellorichakellorich Posts: 3Questions: 0Answers: 0
edited June 2012 in DataTables 1.9
Hello, I am a developer in classic ASP and was wondering how I could use ASP to populate my datatable for reporting and search functionality. I was assuming DataTables would accept primitive JSON data in the format with the example [code] [{"CategoryName":"Expenses","Id":1,"CategoryId":1,"GroupCode":"2210200","GroupName":"Communication"},{"CategoryName":"Expenses","Id":2,"CategoryId":1,"GroupCode":"2210300","GroupName":"Domestic travel and Subsistence"}] [/code] but apparently it's not working. Any Ideas would be helpful.

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin
    > I was assuming DataTables would accept primitive JSON data in the format with the example

    It will indeed :-). You need to tell DataTables two things:

    1. To expect a plain array of data form the Ajax source - done by setting sAjaxDataProp to be an empty string (i.e. "").

    2. Use mDataProp to tell each column which property to populate the table with from the JSON feed: http://datatables.net/blog/Extended_data_source_options_with_DataTables

    Allan
  • akellorichakellorich Posts: 3Questions: 0Answers: 0
    Thanks for your quick response. I am still haveing a problem with the code though. The error that pops up my screen is [quote]DataTables warning (table id = 'positions'): DataTables warning: JSON data from server could not be parsed. This is caused by a JSON formatting error. [/quote]

    the asp code is as follows

    [code]


    $(document).ready(function(){
    //$('#messages').hide()
    $('#successhead').hide()
    $('#errorhead').hide()
    $('button').button()
    $('#positionid').val(0)
    $('#positionname').val("")
    $('#positiondetails').hide()
    $('#positions').dataTable({
    "bJQueryUI": true,
    "sPaginationType": "full_numbers",
    "sDom": '<"H"Tfr>t<"F"ip>',/**/
    //"bProcessing": true,
    "bServerSide": true,
    "sAjaxSource": "results.asp?id=53",
    "sAjaxSource": "",
    "aoColumns": [
    { "mDataProp": "PositionId" },
    { "mDataProp": "PositionDescription" },
    { "mDataProp": "DateAdded" },
    { "mDataProp": "AddedBy" }
    ],
    "oTableTools": {
    "sSwfPath": "media/copy_csv_xls_pdf.swf",
    "aButtons": [ "xls", "print","pdf" ]

    }
    })
    })


    [/code]


    And the output generated from the asp search is

    [code]
    [{"PositionId":"1","PositionDescription":"Program","DateAdded":"6/25/2012 6:07:28 PM","AddedBy":"Admin"},{"PositionId":"2","PositionDescription":"Program Coordinator","DateAdded":"6/25/2012 6:30:48 PM","AddedBy":"Admin"},{"PositionId":"3","PositionDescription":"District Agricultural Officer","DateAdded":"6/25/2012 6:31:47 PM","AddedBy":"Admin"},{"PositionId":"4","PositionDescription":"Provincial Agricultural Officer","DateAdded":"6/25/2012 6:32:01 PM","AddedBy":"Admin"},{"PositionId":"5","PositionDescription":"CIG Trainer","DateAdded":"6/25/2012 6:34:48 PM","AddedBy":"Admin"},{"PositionId":"6","PositionDescription":"Test Test Test","DateAdded":"6/25/2012 6:49:09 PM","AddedBy":"Admin"}]
    [/code]

    What could possibly be the matter?

    Regards

    Richard
  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin
    Could you run your table through the DataTables debugger please, and let me know the unique code (link at below the reply box).

    Allan
  • akellorichakellorich Posts: 3Questions: 0Answers: 0
    Hello again,

    Sorry for the long absence the code generated is uracim

    Please assist

    Thanks again
This discussion has been closed.