confused populating the table

confused populating the table

orkunorkun Posts: 4Questions: 0Answers: 0
edited September 2011 in General
Hello

I am new and confused about populating the data table.

I have an array as "obj" named.

I can use it as ( it seems ok)

data_table.fnAddData ( [obj[0].il,obj[0].ilce,obj[0].koy,obj[0].nakil] );

But in construction as ( it fails )

"aaData": [
[obj[0].il,obj[0].ilce,obj[0].koy,obj[0].nakil]
],


What am I doing wrong ?

you see I used only obj[0] values for testing purposes.

how can I populate the table with whole array ?

kind regards

Ahmet Temiz

Replies

  • fbasfbas Posts: 1,094Questions: 4Answers: 0
    you probably haven't defined obj before the constructor call, or it's out of scope.
  • orkunorkun Posts: 4Questions: 0Answers: 0
    I checked the obj existence before DataTable with obj.length it is ok.
    obj was global variable anyway.

    Is this syntax correct : "aaData": [
    [obj[0].il,obj[0].ilce,obj[0].koy,obj[0].nakil]
    ],

    Besides, when I put < data_table.fnAddData ( [obj[0].il,obj[0].ilce,obj[0].koy,obj[0].nakil] ); >
    in a for loop it is very slow ( totally 1600 records)

    regards
  • allanallan Posts: 63,531Questions: 1Answers: 10,475 Site admin
    fnAddData does an automatic redraw when called without the second parameter being set to false. That would make calling it horribly slow. You want to pass in false there and then once your loop is finished do an fnDraw.

    Allan
  • fbasfbas Posts: 1,094Questions: 4Answers: 0
    but if you have a obj set (as an array of objects) you could use
    [code]
    "aaData": obj
    "aoColumns": [
    { "mDataProp": il },
    { "mDataProp": ilce },
    { "mDataProp": koy },
    { "mDataProp": nakil }
    ]
    [/code]

    right?

    http://www.datatables.net/ref#mDataProp
  • orkunorkun Posts: 4Questions: 0Answers: 0
    I used "aaData": obj
    as
    [object Object],[object Object],[object Object]

    also
    "aaData": jsonData

    as:

    [{"hey_no":0,"list_gmaplat":30.91122037132634,"list_gmaplong":40.75985746149354,"nakil":9,"il":"duzce","ilce":"golyaka","koy":"degirmentepe"},
    ....

    ]

    all failed
This discussion has been closed.