sColumns not defined and data doesn load

sColumns not defined and data doesn load

mrkevansmrkevans Posts: 17Questions: 0Answers: 0
edited December 2009 in General
I am working on getting serverside processing to work.

Below is the code i have going, but i get the error on page load "sColumns" not defined.
And when i use my filter fields, the filter works, i see my json arrays sent back, but they don't load.
What am i missing?


[code]
var oTable =$('#admin_user_index_table').dataTable({
"bJQueryUI": true,
"sPaginationType": "full_numbers",
"bAutoWidth":true,
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "/admin/users/reports/2",
"aoColumns":
[
{
"sName":"zjUserID",
"sWidth":"50px"
},
{
"sName":"timeCreate"
},
{
"sName":"timeLastAccess"
},
{
"sName":"lastName"
},
{
"sName":"activeListings"
},
{
"sName":"soldListings"
},
{
"sName":"unsoldListings"
},
null,
{
"sName":"totalListings"
},
{
"sName":"deviceID"
},
{
"sName":"ebayUserID"
},
{
"sName":"status"

}
]


});
[/code]

Here is what i am getting back [code]
{"iTotalDisplayRecords":0,"sEcho":["8"],"aaData":[["000000177","2009-11-09 22:36:18","2009-11-12 03:12:20","Evans, Mark","1","0","0","1",0,"dfdfdfd242424","cmm","1"]]}
[/code]

Which looks just fine.
here is my html
[code]


User ID
Since
Last Access
Name
Active
Sold
Unsold
Total
Due
Device
EbayID
Status




a
b
c
d
e
f
g
h
i
j
k
l


aa
bb
cc
dd
ee
ff
gg
hh
ii
jj
kk
ll












$$$






[/code]

Replies

  • mrkevansmrkevans Posts: 17Questions: 0Answers: 0
    Also i am using 1.5.4
  • allanallan Posts: 61,744Questions: 1Answers: 10,111 Site admin
    Hi mrkevans,

    Very curious! The variable 'sColumns' is used by DataTables only for reordering columns (by name), and is entirely optional. Could you post a link showing the issue, or the line number of the error (for the un-minified source).

    Also one thing that might effect this (although it would be a weird interaction), I notice that your sEcho is an array. It shouldn't be - it should just be a straight string echo rather than an array of strings. It's possible that changing this will fix the issue, since I can't see anything else wrong with it...

    Regards,
    Allan
  • mrkevansmrkevans Posts: 17Questions: 0Answers: 0
    Hey Thanks for the quick reply,
    Below is the expanded Firebug code, and below is the actual error on line 4090
    [code]
    sColumns is undefined
    _fnReOrderIndex(Object sInstance=admin_user_index_table oFeatures=Object, Object name=sColumns)jquery.d...Tables.js (line 4090)
    _fnAjaxUpdateDraw(Object sInstance=admin_user_index_table oFeatures=Object, Object iTotalDisplayRecords=0 sEcho=[1] aaData=[10])jquery.d...Tables.js (line 2811)
    anonymous(Object iTotalDisplayRecords=0 sEcho=[1] aaData=[10])jquery.d...Tables.js (line 2764)
    I()jquery-1....2.min.js (line 19)
    anonymous(-5)jquery-1....2.min.js (line 19)
    [Break on this error] var aColumns = sColumns.split(',');\n
    [/code]



    sColumns is undefined
    http://local.admin.com/js/jquery/plugins/dataTables-1.5/media/js/jquery.dataTables.js
    Line 4090


    Below is the code that loads on table load. I changed sEcho to a string, and im getting the same thing.

    [code]
    {"iTotalDisplayRecords":0,"sEcho":"1","aaData":[["000000102","2009-10-27 21:14:15","2009-11-13 22:36:38","Purd, T","0","0","6","6",0,"adfs","testuser_xx1","0"],["000000105","2009-10-27 21:17:32","2009-11-13 21:23:45",", ","1","0","7","8",0,"woeriu","testuser_xx8","1"],["000000108","2009-10-27 21:34:07","2009-11-09 21:59:02",", ","0","0","6","6",0,"qewr","testuser_xx0_dev","1"],["000000118","2009-10-27 22:39:19","2009-11-05 02:44:40",", ","1","0","3","4",0,"lkj;","testuser_xx90_dev","1"],["000000137","2009-10-29 15:16:17","2009-11-12 21:58:10",", ","6","1","3","10",1.99,"00000000-0000-1000-8000-eiru","testuser_xx88","1"],["000000144","2009-11-03 00:30:22","2009-11-13 20:08:56",", ","2","0","3","5",0,"wqer","testuser_xx7","1"],["000000149","2009-11-04 21:36:23","2009-11-10 19:46:26",", ","2","2","7","11",3.98,"qerw","testuser_xx5","1"],["000000150","2009-11-04 22:14:56","2009-11-10 01:10:59",", ","2","0","2","4",0,"qerw","testuser_xx3","1"],["000000157","2009-11-05 03:01:00","2009-11-07 00:14:08",", ","0","0","1","1",0,"qwer","testuser_xx8_dev","1"],["000000173","2009-11-09 19:29:21","2009-11-13 00:27:28",", ","0","1","4","5",1.99,"asdf","testuser_xx9","1"]]}[/code]
  • allanallan Posts: 61,744Questions: 1Answers: 10,111 Site admin
    Hi mrkevans,

    Thanks very much for the reply! You have indeed encountered and discovered a bug in DataTables - thanks very much for taking the time to report it to me! The issue is on line 2808:

    [code]
    var bReOrder = (json.sColumns != 'undefined' && sOrdering !== "" && json.sColumns != sOrdering );
    [/code]
    it should be:

    [code]
    var bReOrder = (typeof json.sColumns != 'undefined' && sOrdering !== "" && json.sColumns != sOrdering );
    [/code]
    The issue was the bReOrder was being assigned to be true (when sOrdering wasn't null), and therefore causing this error. This fix will be in the next release of DataTables (which should be fairly soon).

    One other thing I noticed in your JSON return, you don't have "iTotalRecords" defined - which is actually a required parameter: http://datatables.net/usage/server-side .

    Regards,
    Allan
  • mrkevansmrkevans Posts: 17Questions: 0Answers: 0
    Awesome! that fixed it, my data loaded and no more error message.

    One last thing. I found this :http://www.sprymedia.co.uk/article/DataTables on your site where you define all the initialization stuff, but i can't find that anywhere on the http://www.datatables.net/api, yet your first paragraph refers to it being "above". Are you upgrading that at the moment?

    Thanks again for all your help and hard work!
    This is truly an awesome tool.

    Thanks so much,

    Mark
  • allanallan Posts: 61,744Questions: 1Answers: 10,111 Site admin
    Hi Mark,

    Excellent - good to hear that did the trick for you.

    The initialisation object is fully described on this site in the 'Usage' section ( http://www.datatables.net/usage/ ) - click on the sub-menu (Features, Columns etc) to see the individual parameters, grouped into similar areas.

    I've updated the text on the API page to reflect this and provide a link (I suspect it was a copy and paste error from the old pages :-) ).

    Regards,
    Allan
This discussion has been closed.