Buttons with Slotted content

59 of 116
To modify the internal button's icon or checkbox, you must directly tell the button which piece of it you are replacing. You do this by adding the appropriate [slot] to your replacement.
Result Full HTML CSS JS
Edit Download
Delete

Full Code

<!DOCTYPE html>
<html>

<head>
  <meta charset="utf-8">
  <title>ZingGrid Demo</title>
  <script src="https://cdn.zinggrid.com/dev/zinggrid-dev.min.js" defer></script>
  <style>
    body {
      background: #e6e6e6;
    }

    zing-grid[loading] {
      height: 325px;
    }
  </style>
</head>

<body>
  <zing-grid caption="Slotted Content" editor="modal" layout="row" layout-controls="disabled" viewport-stop>
    <zg-data data='[
        {
          "name": "Tom"
        },
        {
          "name": "Thorton"
        },
        {
          "name": "Timmy"
        },
        {
          "name": "Turner"
        }
      ]'></zg-data>
    <zg-colgroup>
      <zg-column index="name"></zg-column>
      <!-- custom column for delete button -->
      <zg-column index="custom" header="Delete Row" editor="false">
        <zg-button action="removerecord">
          <span name="close" slot="icon">❌ </span>
          <em slot="label" class="test"> Delete</em>
        </zg-button>
      </zg-column>
    </zg-colgroup>
  </zing-grid>
  <script></script>
</body>

</html>
<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>ZingGrid Demo</title>
    <script src="https://cdn.zinggrid.com/dev/zinggrid-dev.min.js" defer></script>
  </head>
  <body>
    <zing-grid 
      caption="Slotted Content"
      editor="modal" 
      layout="row" 
      layout-controls="disabled" 
      viewport-stop>
      <zg-data data='[
        {
          "name": "Tom"
        },
        {
          "name": "Thorton"
        },
        {
          "name": "Timmy"
        },
        {
          "name": "Turner"
        }
      ]'></zg-data>
      <zg-colgroup>
        <zg-column index="name"></zg-column>
        <!-- custom column for delete button -->
        <zg-column index="custom" header="Delete Row" editor="false">
					<zg-button action="removerecord">
            <span name="close" slot="icon">❌ </span> 
            <em slot="label" class="test"> Delete</em>
          </zg-button>
        </zg-column>
      </zg-colgroup>
    </zing-grid>
	</body>
</html>
body { background:#e6e6e6; }

Interested in this demo? Modify it to your needs in ZingSoft Studio, our testing sandbox. It's free to sign up, and you can come back and edit at any time!

Edit in Studio

Demo Gallery