Articles in this section

How to change default group caption based on condition in Vue DataGrid?

This article explains how to change the default group caption based on a condition in Vue Data Grid. Default group caption content can be customized using the captionTemplate feature of Vue Data Grid groupSettings. You can customize the group caption content based on condition for specific values. This can be achieved using the dataBound event of the DataGrid. In the dataBound event, the custom icons have been rendered in the group caption based on the grouped column values.

The caption template for the boolean 'Verified' column has been changed based on the condition in the following demo.

  methods: {
      bound(args) {
          var captionTemplate = document.getElementsByClassName("e-groupcaption");
         for (var i = 0; i < captionTemplate.length; i++) {
             if (captionTemplate[i].innerText === "false") {
                 var node = document.createElement("span");
                 node.className = "e-icons e-search";
                 node.width = "50px";
                 node.height = "50px";
                 node.style.position = "absolute";
                 node.style.marginLeft = "5px";
                 node.style.paddingTop = "3px";
                 captionTemplate[i].appendChild(node);
        } else {
                var element = document.createElement("span");
                element.className = "e-icons e-upload";
                element.width = "50px";
                element.height = "50px";
                element.style.position = "absolute";
                element.style.marginLeft = "5px";
                element.style.paddingTop = "3px";
                captionTemplate[i].appendChild(element);
       }
      }
    }
  }

 

Output


Caption Template in Vue Grid

 

Refer to the working sample for additional details and implementation: Vue Sample

 

Documentation:

https://ej2.syncfusion.com/vue/documentation/grid/grouping/grouping#caption-template

Conclusion

We hope you enjoyed learning how to change default group caption based on condition in Vue DataGrid.

You can refer to our Vue Data Grid feature tour page to learn about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications. You can also explore our example to understand how to create and manipulate data.

For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion®, you can try our 30-day free trial to check out our other controls.

If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forumsBoldDesk Support, or feedback portal. We are always happy to assist you! 

 

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Access denied
Access denied