Manipulate ajax rendered data

Manipulate ajax rendered data

islamelshobokshyislamelshobokshy Posts: 99Questions: 20Answers: 1
edited May 2018 in Free community support

My json returned data have this form :

"status":"success",
"data":[  
   {  
      "A":"A",
      "B":"B",
      "C":"773",
      "D":"0.00",
      "F":"0",
    .. etc
  },
  {
      "A":"A",
      "B":"B",
      "C":"773",
      "D":"0.00",
      "E":"0",
    .. etc
  },
  .. etc

I want to only take these results from the table :

"status":"success",
"data":[  
   {  
      "A":"A",
      "C":"773",
      "E":"0",
    .. etc
  },
  {
      "A":"A",
      "C":"773",
      "E":"0",
    .. etc
  },
  .. etc

How can I do this ? In other words, only take certain results to be rendered in my table.

This question has an accepted answers - jump to answer

Answers

  • islamelshobokshyislamelshobokshy Posts: 99Questions: 20Answers: 1

    Knowing that, for example, the first 3 data will be used in the th in the body, the next 3 will be used in the tfoot, and the last 2 won't be used anywhere... How can I achieve such a 'complex' manipulation?

  • islamelshobokshyislamelshobokshy Posts: 99Questions: 20Answers: 1

    In other words, I want to be able to control what is being drawn and where from the json inside my DataTables. I'm sorry for the multiple posts, I can't edit my previous one... I can't seem to find out anything about this in the forums.

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    Hi @islamelshobokshy ,

    Take a look at the orthogonal data example here, this should help. This shows how to pull out fields from the JSON while ignoring the rest.

    I don't understand what you mean by "the next 3 will be used in the tfoot" - there is only a single (well, limited) tfoot, so I don't see how you want to use data from each record to populate it.

    Cheers,

    Colin

  • islamelshobokshyislamelshobokshy Posts: 99Questions: 20Answers: 1

    Let me try to explain more clearly :
    I have a data object containing multiple data for each row. In each of this row's data there are 10 columns. A, B, C, D .. etc, each having a unique key. I want to populate the body with A, B, E. And the footer with F, G, K. Is that possible? Otherwise I'll have to pass 2 json files, one for the body and one for the footer to be used.

  • colincolin Posts: 15,240Questions: 1Answers: 2,599
    Answer ✓

    So if you've got 100 rows, that's 100 F,G,Ks for the footer!? How would that work?

  • islamelshobokshyislamelshobokshy Posts: 99Questions: 20Answers: 1

    They would be the same values for all of them, so if the footer uses data[0].element it would be fine. it's okay tho I managed by another mean

This discussion has been closed.