Home > Enterprise >  Creating sequential numbers in the auto table jspdf column VusJs
Creating sequential numbers in the auto table jspdf column VusJs

Time:03-19

enter image description here

    columns: [
      {
        header: 'No',
        dataKey: 'Index',
      },
      { header: 'No Registrasi', dataKey: 'no_register' },
      { header: 'Kode Partai', dataKey: 'kode_partai' },
      { header: 'Sumber', dataKey: 'kode_partai' },
      { header: 'Tanggal Panen', dataKey: 'tanggal_panen' },
      { header: 'Tanggal Terima', dataKey: 'tanggal_penerima' },
    
    ],
{
    "success": true,
    "message": "Data ditemukan",
    "data": [
        {
            "id": 15,
            "user_id": 3,
            "no_register": "KREO",
            "kode_partai": "00PPPP",
            "legal_source": "Terdaftar",
            "jenis_sbw_kotor": "9000",
            "tanggal_panen": "2022-02-10",
            "tanggal_penerima": "2022-02-16",
            "alamat": "jl kandir",
            "no_kendaraan": "K 8992993 KW",
            "jumlah_sbw_kotor": "9000",
            "jumlah_pcs": "9000",
            "jumlah_box": "90999",
            "kadar_air": "9000",
            "warna": "Cream",
            "kondisi": "ok",
            "status": "Adding",
            "harga_kulak": "900000000",
            "created_at": "2022-02-24T05:48:07.000000Z",
            "updated_at": "2022-02-24T05:48:07.000000Z"
        },
        {
            "id": 16,
            "user_id": 3,
            "no_register": "KREO",
            "kode_partai": "00PPPP",
            "legal_source": "Terdaftar",
            "jenis_sbw_kotor": "9000",
            "tanggal_panen": "2022-02-10",
            "tanggal_penerima": "2022-02-16",
            "alamat": "jl kandir",
            "no_kendaraan": "K 8992993 KW",
            "jumlah_sbw_kotor": "9000",
            "jumlah_pcs": "9000",
            "jumlah_box": "90999",
            "kadar_air": "9000",
            "warna": "Cream",
            "kondisi": "ok",
            "status": "Adding",
            "harga_kulak": "900000000",
            "created_at": "2022-02-24T05:48:07.000000Z",
            "updated_at": "2022-02-24T05:48:07.000000Z"
        }
    ]
}

I've tried to use index 1, but it doesn't work. I want my dataKey to be filled with sequential numbers according to the number of Arrays I get from the api service's response. in what other way so that I can enter the serial number in the 'NO' column.I use Vuejs

CodePudding user response:

You could add a index field to your data with the map function.


const dataWithIndex = serverResponse.data.map((d,i) => ({...d,Index:i 1}));

  • Related