This is a migrated thread and some comments may be shown as answers.

Get MS_Description for a column

1 Answer 103 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Fabio
Top achievements
Rank 1
Fabio asked on 11 Nov 2020, 02:42 PM
Hi, I would like to know if there is a way to get a sql db column  MS_Description as a column name tooltip  from the standard object used to describe a grid element:

columns.Bound(p => p.Country).Title("Country").Visible(true);

1 Answer, 1 is accepted

Sort by
0
Anton Mironov
Telerik team
answered on 13 Nov 2020, 10:42 AM

Hi Fabio,

In order to set the Kendo UI Tooltip to a property of an object (Db column), I would recommend the following:

  • Set the column that should take the tooltip. Add a custom class, that will help for the filtering of the tooltip:
    columns.Bound(p => p.ShipCity).HtmlAttributes(new { @class = "forTooltips" });
  • Define the Tooltip for the Grid and use the class of the column from above as a filter:
    @(Html.Kendo().Tooltip()
          .For("#grid")
          .Filter(".forTooltips")
          .ContentHandler("getRatingTooltip")
          .Position(TooltipPosition.Right)
          .AutoHide(false)
    )
  • The ContentHandler of the Tooltip will execute a JavaScript function ("getRatingTooltip" in the example). In the function handler, get and return the needed property of the object. It will be set as a Tooltip out of the box. The property doesn't need to be visible in the Grid by default. Here is an example of the function handler:
        function getRatingTooltip(e) {
            var dataItem = $("#grid").data("kendoGrid").dataItem(e.target.closest("tr"));
            var content = dataItem.ShipName;
            return content;
        }

Find attached a sample project with the needed implementations included. 

After making the needed tests locally, let me know if further assistance is needed.

Kind Regards,
Anton Mironov
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
Grid
Asked by
Fabio
Top achievements
Rank 1
Answers by
Anton Mironov
Telerik team
Share this question
or