Articles in this section
Category / Section

How to render customized Tooltip for one column which displays values of another column?

2 mins read

We may like to customize the default browser tooltip displayed in the grid columns which can be achieved using the ejTooltip control of Syncfusion.


The default tooltip of the grid columns can be customized by using cssClass property of column for which we need customized tooltip.


<script type="text/javascript">  
       $(function () {                    
                    dataSource: window.gridData,
                    allowPaging: true,
                    columns: [
                            { field: "OrderID", isPrimaryKey: true, headerText: "Order ID" },
                            { field: "CustomerID", headerText: 'Customer ID'},
                            { field: "EmployeeID", headerText: 'Employee ID', cssClass: "coltip" },
                            { field: "Freight", format: "{0:C}"  },
                            { field: "OrderDate", format: "{0:MM/dd/yyyy}" },
                            { field: "ShipCountry", headerText: "Ship Country" },
                            { field: "ShipCity", headerText: 'Ship City'}
                    dataBound: "onDataBound"                    



            .Columns(col =>
                        col.Field("OrderID").HeaderText("Order ID").IsPrimaryKey(true).Add();
                        col.Field("CustomerID").HeaderText("Customer ID").Add();
                        col.Field("EmployeeID").HeaderText("Employee ID").CssClass("coltip").Add();
                        col.Field("ShipCountry").HeaderText("Ship Country").Add();
                        col.Field("ShipCity").HeaderText("Ship City").Add();                        



<ej:Grid ID="Grid" runat="server" AllowPaging="True"> 
            <ClientSideEvents DataBound="onDataBound" />
                <ej:Column Field="OrderID" HeaderText="Order ID" IsPrimaryKey="True" />
                <ej:Column Field="CustomerID" HeaderText="Customer ID" />
                <ej:Column Field="EmployeeID" HeaderText="Employee ID" CssClass="coltip" />
                <ej:Column Field="Freight" Format="{0:C}" />
                <ej:Column Field="OrderDate" Format="{0:MM/dd/yyyy}"/>
                <ej:Column Field="ShipCountry" HeaderText="Ship Country" />
                <ej:Column Field="ShipCity" HeaderText="Ship City" />


In the dataBound event of the Grid, we need to render the ejTooltip control for the elements with class name “coltip”.

<script type="text/javascript"> 
    function onDataBound(args) { 
            width: "350px", 
            content: '<div class="main"> <div class="poster"> <img src="" width="150px" height="120px"> </div> <div class="def"> <h4> Roslyn Succinctly </h4><div class="description">Microsoft has only recently embraced the world of open source software, offering <a href="#">More...</a> </div>'  



We can also display another column value in the customized tooltip using the beforeOpen event of the ejTooltip control.


<script type="text/template" id="test"> 
    <div id="custom">This is the customized tooltip which shows another column ie {{:ShipName}} value.</div>//customize the tooltip styles 
<script type="text/javascript"> 
    var temp = $.templates(test); 
    function onDataBound(args) { 
            width: "350px", 
            //content: 'some content' 
            beforeOpen: function (args) { 
                if ($("e-headercell", "e-headercelldiv")) {
 //check if headercell is hovered 
                    args.cancel = true; 
                var gridObj = $("#Grid").data("ejGrid"); 
                var index = gridObj.getIndexByRow("tr")); 
                var val = gridObj.getCurrentViewData()[index]; //get the row data 
                $(".coltip").ejTooltip({ content: temp.render(val) });//render the template with row data and display it as content for tooltip 



Custom tooltip

Did you find this information helpful?
Help us improve this page
Please provide feedback or comments
Please sign in to leave a comment