Add Custom Class to Grid Command CELL

1 Answer 5213 Views
Grid
Eric J at FADV
Top achievements
Rank 1
Eric J at FADV asked on 06 Apr 2016, 02:27 AM
How can I add a custom class name to the grid CELL (not the buttons) of a command cell, and have it so that when new rows are added in batch edit mode, the classes are attached. I see no "attributes" attribute for the command cell.
Iliana Dyankova
Telerik team
commented on 07 Apr 2016, 10:36 AM

Hi Eric,
 
To achieve this you could use the columns.attributes option. As an example: 
//....
columns: [
    //....    
   {attributes: {
       "class": "customClass",
   }, command: { text: "View Details" }, title: " " }
],


Regards,
Iliana Nikolova
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Eric J at FADV
Top achievements
Rank 1
commented on 08 Apr 2016, 04:37 PM

Thanks, but I am looking to apply a custom class to the command columns cells only, not all columns in the grid.

1 Answer, 1 is accepted

Sort by
0
Accepted
Konstantin Dikov
Telerik team
answered on 12 Apr 2016, 07:30 AM
Hello Eric,

As documented in the columns.attributes section in our API reference article, the attributes are added to the TD elements for the column where they are set and not to all columns. If you need to apply that custom attribute to the command column you need to set them in that column's definition:
<div id="grid"></div>
<script>
$("#grid").kendoGrid({
  columns: [
    { field: "name" },
    { command: "destroy",
     attributes: {
      "class": "table-cell"
     }
    }
  ],
  editable: true,
  dataSource: [ { name: "Jane Doe" } ]
});
</script>

Hope this helps.


Regards,
Konstantin Dikov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Grid
Asked by
Eric J at FADV
Top achievements
Rank 1
Answers by
Konstantin Dikov
Telerik team
Share this question
or