No More Posting New Topics!

If you have a question or an issue, please start a thread in our Github Discussions Forum.
This forum is closed for new threads/ topics.

Navigation

    Quasar Framework

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    Export to csv objects and array of objects

    Help
    2
    3
    826
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • G
      Gorgc last edited by Gorgc

      How to export all these data to csv from q-table? The special_rewards_attributes is an array of objects, what is the best way to achieve this?

      {
          "levels": [
              {
                  "id": 9,
                  "name": "Level 31",
                  "active": "f",
                  "conditionValue": 21,
                  "description": "Hello World",
                  "minOrder": 23,
                  "rewardCode": "RC41",
                  "rewardName": "qwe",
                  "rewardValue": 12,
                  "special_rewards_attributes": [
                      {
                          "id": 1,
                          "level_id": 9,
                          "active": "t",
                          "endAt": "2021-02-03T01:00:00.000Z",
                          "rewardCode": "RC41",
                          "rewardName": "Reward Test",
                          "startAt": "2021-02-02T01:00:00.000Z",
                          "value": "100"
                      }
                  ]
              },
              {
                  "id": 10,
                  "name": "TestOnly",
                  "active": "f",
                  "conditionValue": 123,
                  "description": "asd",
                  "minOrder": 123,
                  "rewardCode": "qweasdasdaa11",
                  "rewardName": "qwe",
                  "rewardValue": 123,
                  "special_rewards_attributes": [
                      {
                          "id": 12,
                          "level_id": 10,
                          "active": "t",
                          "endAt": "2021-02-09T00:00:00.000Z",
                          "rewardCode": "123testEdited",
                          "rewardName": "Reward H",
                          "startAt": "2021-02-08T00:00:00.000Z",
                          "value": "250"
                      }
                  ]
              },
              {
                  "id": 7,
                  "name": "TestUser",
                  "active": "t",
                  "conditionValue": 11,
                  "description": "asd",
                  "minOrder": 112,
                  "rewardCode": "qweasdasd",
                  "rewardName": "asdwqe",
                  "rewardValue": 50,
                  "special_rewards_attributes": []
              },
              {
                  "id": 6,
                  "name": "amirul",
                  "active": "t",
                  "conditionValue": 12,
                  "description": "test",
                  "minOrder": 32,
                  "rewardCode": "qweasd",
                  "rewardName": "qwe",
                  "rewardValue": 12,
                  "special_rewards_attributes": []
              },
              {
                  "id": 12,
                  "name": "sxs",
                  "active": "t",
                  "conditionValue": 10,
                  "description": "sds",
                  "minOrder": 12,
                  "rewardCode": "dede12",
                  "rewardName": "cdc",
                  "rewardValue": 10,
                  "special_rewards_attributes": []
              },
              {
                  "id": 13,
                  "name": "xdc",
                  "active": "t",
                  "conditionValue": 2,
                  "description": "sdxs",
                  "minOrder": 12,
                  "rewardCode": "cdc12",
                  "rewardName": "xed",
                  "rewardValue": 11,
                  "special_rewards_attributes": []
              },
              {
                  "id": 14,
                  "name": "qweqwe",
                  "active": "f",
                  "conditionValue": 123,
                  "description": "1231sdqsdqsd",
                  "minOrder": 23232,
                  "rewardCode": "35356sdqsdqwe",
                  "rewardName": "qsdetg34",
                  "rewardValue": 123132,
                  "special_rewards_attributes": [
                      {
                          "id": 14,
                          "level_id": 14,
                          "active": "t",
                          "endAt": "2021-02-13T00:00:00.000Z",
                          "rewardCode": "123werwerrrr",
                          "rewardName": "Reward I",
                          "startAt": "2021-02-10T00:00:00.000Z",
                          "value": "500"
                      }
                  ]
              },
              {
                  "id": 11,
                  "name": "testlevelformanyreward",
                  "active": "f",
                  "conditionValue": 123,
                  "description": "qwe",
                  "minOrder": 123,
                  "rewardCode": "qwe",
                  "rewardName": "qwe",
                  "rewardValue": 123,
                  "special_rewards_attributes": [
                      {
                          "id": 8,
                          "level_id": 11,
                          "active": "t",
                          "endAt": "2021-02-05T00:00:00.000Z",
                          "rewardCode": "qwseqd",
                          "rewardName": "Reward E",
                          "startAt": "2021-02-02T00:00:00.000Z",
                          "value": "150"
                      },
                      {
                          "id": 9,
                          "level_id": 11,
                          "active": "t",
                          "endAt": "2021-02-05T00:00:00.000Z",
                          "rewardCode": "qwedqsd",
                          "rewardName": "Reward F",
                          "startAt": "2021-02-02T00:00:00.000Z",
                          "value": "100"
                      },
                      {
                          "id": 4,
                          "level_id": 11,
                          "active": "t",
                          "endAt": "2021-02-05T00:00:00.000Z",
                          "rewardCode": "ABC",
                          "rewardName": "Reward A",
                          "startAt": "2021-02-02T00:00:00.000Z",
                          "value": "200"
                      },
                      {
                          "id": 5,
                          "level_id": 11,
                          "active": "f",
                          "endAt": "2021-02-05T00:00:00.000Z",
                          "rewardCode": "ABC34",
                          "rewardName": "Reward B",
                          "startAt": "2021-02-02T00:00:00.000Z",
                          "value": "10"
                      },
                      {
                          "id": 6,
                          "level_id": 11,
                          "active": "t",
                          "endAt": "2021-02-05T00:00:00.000Z",
                          "rewardCode": "RC32",
                          "rewardName": "Reward C",
                          "startAt": "2021-02-02T00:00:00.000Z",
                          "value": "20"
                      },
                      {
                          "id": 7,
                          "level_id": 11,
                          "active": "f",
                          "endAt": "2021-02-05T00:00:00.000Z",
                          "rewardCode": "EG54",
                          "rewardName": "Reward D",
                          "startAt": "2021-02-02T00:00:00.000Z",
                          "value": "50"
                      }
                  ]
              },
              {
                  "id": 15,
                  "name": "Test123",
                  "active": "t",
                  "conditionValue": 123,
                  "description": "qwe",
                  "minOrder": 123,
                  "rewardCode": "qweasad",
                  "rewardName": "asda",
                  "rewardValue": 123,
                  "special_rewards_attributes": []
              },
              {
                  "id": 16,
                  "name": "testnew",
                  "active": "t",
                  "conditionValue": 123,
                  "description": "qwe",
                  "minOrder": 123,
                  "rewardCode": "qwe",
                  "rewardName": "qwe",
                  "rewardValue": 123,
                  "special_rewards_attributes": []
              }
          ]
      }
      

      This is my table

      forum2.png

      and this is the result i get from exporting to csv, the special rewards shown as [object Object]

      forum.png

      For my code, I’m following this guide from quasar docs

      https://quasar.dev/vue-components/table#Exporting-data

      dobbel 1 Reply Last reply Reply Quote 0
      • dobbel
        dobbel @Gorgc last edited by

        @gorgc

        Because of the nested data structure of your table , the QTable export to csv function does not know how to handle this. You’ll have to create your own export function:

        https://quasar.dev/vue-components/table#Exporting-data

        G 1 Reply Last reply Reply Quote 0
        • G
          Gorgc @dobbel last edited by

          @dobbel Alright, thank you

          1 Reply Last reply Reply Quote 0
          • First post
            Last post