aoColumns, aoColumnDefs with javascript data source

aoColumns, aoColumnDefs with javascript data source

keturnketurn Posts: 18Questions: 0Answers: 0
edited June 2010 in Bug reports
I just upgraded to 1.7beta3 for the column width fixes (nice work!), and I started looking at aoColumnDefs, as that flexibility looks useful. Being a little unsure how to go about changing my existing code, I just changed

{ aaData: [...], aoColumns: [...] } to { aaData: [...], aoColumnDefs: [...] }

and datatables died with "Uncaught TypeError: Cannot read property 'length' of null" on line 6001 (in the "Columns" section of the constructor, nThs is null.)

The element I'm applying datatables to is just " " (this project doesn't really speak "progressive enhancement").

I think the right thing to do for my use case is probably keep the aoColumns in there *and* add aoColumnDefs as needed, but I thought I'd submit this as a bug report as "Uncaught TypeError" is probably not the interface you wanted for this.

Thanks!

Replies

  • allanallan Posts: 63,689Questions: 1Answers: 10,500 Site admin
    Hi keturn,

    Could you perhaps post your initialisation code for me? I haven't actually tried aoColumnDefs with aaData I don't think (I'll do so shortly). In theory the change that is needed for aoColumnDefs should simply be the name change, and adding aTargets[] to the column definition.

    Regards,
    Allan
  • keturnketurn Posts: 18Questions: 0Answers: 0
    edited June 2010
    Here's an example of what I'm passing to jQuery(selector).dataTable:

    [code]
    {"aaData":[
    [13,5,"early",1,44607600000,null],[7,4,"paint stuff",1,203986800000,null],
    [6,4,"buy stuff",1,946670399000,null],[8,4,"eat great fries",1,1347087600000,null],
    [12,5,"late task",1,1590994800000,null],[1,1,"step one",1,null,null]],
    "aaSorting":[[4,"asc"]],
    "aoColumnDefs":[
    {"aTargets":[0],"bSearchable":false,"sClass":"taskID hide","sType":"numeric"},
    {"aTargets":[1],"sClass":"tPlan","sTitle":"plan"},
    {"aTargets":[2],"sClass":"tName","sTitle":"name"},
    {"aTargets":[3],"sClass":"tOwner","sTitle":"owner"},
    {"aTargets":[4],"bUseRendered":"false","sClass":"tDue","sTitle":"due","sType":"date"},
    {"aTargets":[5],"sClass":"cT","sTitle":"done"}],
    "bFilter":false,"bInfo":false,"bPaginate":false}
    [/code]
  • keturnketurn Posts: 18Questions: 0Answers: 0
    It's a little unclear how the targets work with aoColumnDefs on a javascript source. Targeting by index seems to work. Trying to target using a string doesn't seem to match anything useful though.
  • shanimalshanimal Posts: 6Questions: 0Answers: 0
    Using aoColumnDefs with aaData would be extremely useful. Is this not currently an option?
  • allanallan Posts: 63,689Questions: 1Answers: 10,500 Site admin
    Yes - it should work just fine. Can you link to a test case showing it not working please?

    Allan
This discussion has been closed.