columns.Select().Title not displaying title in header

1 Answer 47 Views
Grid
Brian
Top achievements
Rank 1
Brian asked on 08 Jul 2024, 03:13 PM

I have a grid in which I am using the columns.Select (see code below) and want a title to display next to the check box in the header where the user clicks the check box to select all rows. There is Title property but when I give it a value it does not display in the header as the other titles do.

This is what I have

 .Columns(columns =>
            {                
                columns.Bound(i => i.lotNumber).Title("Lot Number").Width(100);
                columns.Bound(i => i.lotLocation).Title("Lot Location").Width(100);
                columns.Bound(i => i.lotQuantity).Title("Lot Quantity").Width(100).ClientFooterTemplate("Total: #=sum#"); 
                columns.Bound(i => i.plannedStartDate).Title("Planned Start Date").Width(100).Format("{0:MM/dd/yyyy}");
                columns.Bound(i => i.batchDueDate).Title("Batch Due Date").Width(100).Format("{0:MM/dd/yyyy}");                  
                columns.Select().Title("Pulled").Width(100);                   
               })

Below is a screenshot of the results. I want the text Pulled next to the check box in the header.

1 Answer, 1 is accepted

Sort by
0
Mihaela
Telerik team
answered on 11 Jul 2024, 01:53 PM

Hello Brian,

Since you have submitted the same query as a support ticket, as my colleague answered your question in the ticket, I will post the answer here in case someone else has the same question:

A Select column does not render a title by design. Even though the title option is inherited, for the Select column it doesn't work. The title can be set by using the Grid's dataBound event and a HeaderHtmlAttributes in the column. Here's an example: https://netcorerepl.telerik.com/GSuVbkYV51HLhlBJ25

  1. A custom class is set to the column header:
  2. columns.Select().HeaderHtmlAttributes(new { @class = "grid-select-header" }).Width(100)
  3. A handler attached to the DataBound event:
  4. .Events(ev => ev.DataBound("onDataBound"))
  5. In the handler, finding the element that has the class applied through the HeaderHtmlAttributes option and appending a span element that contains the desired title text:
<script>
    function onDataBound(e) {
        $(".grid-select-header").append("<span style='margin-left: 10px;'>Pulled</span>");
    }
</script>

Regards,
Mihaela
Progress Telerik

Stay tuned by visiting our public roadmap and feedback portal pages. If you're new to the Telerik family, be sure to check out our getting started resources, as well as the only REPL playground for creating, saving, running, and sharing server-side code.
Tags
Grid
Asked by
Brian
Top achievements
Rank 1
Answers by
Mihaela
Telerik team
Share this question
or