0

Im table using gridjs first time and im newbie at js items. How can i set a button? and how can i get link it?

        <script>
        new gridjs.Grid({
            columns: ["#ID", "Ürün Adı", "Ürün Durumu", "Marka", "Seri No", "Nerede",  "İşlem"],
            pagination: {
                limit: 7
            },
            sort: !0,
            search: !0,
            data: [
                [
                    "1",
                    "Iphone 13",
                    "Kullanımda",
                    "Apple",
                    "MN4564323",
                    "Yağız Savaş",
                    "button will be here, i need 2 buttons",
                ],
            ],
        }).render(document.getElementById("table-gridjs"));
    </script>
Kuldeep J
  • 382
  • 5
  • 12

1 Answers1

3

You put it in columns array. Something like this.

<script>
    new gridjs.Grid({
        columns: ["#ID", "Ürün Adı", "Ürün Durumu", "Marka", "Seri No",  "Nerede",  "İşlem",{
            name: 'Buttons',
            formatter: (_, row) =>
                    gridjs.html(`<a href="#" onclick="save( '${row.cells[0].data}');" target="_blank">Example</a>`)
            
            }

], pagination: { limit: 7 }, sort: !0, search: !0, data: [ [ "1", "Iphone 13", "Kullanımda", "Apple", "MN4564323", "Yağız Savaş", "button will be here, i need 2 buttons", ], ], }).render(document.getElementById("table-gridjs"));

ytkn
  • 73
  • 4