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

Set data-title attribute to every <td> cell

1 Answer 665 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Pantulu
Top achievements
Rank 1
Pantulu asked on 19 Mar 2015, 03:01 PM
I am into customizing the display of kendo grid in mobile devices.

I need to know if I can achieve this.
I need to set the data-title={the corresponding header title} to each corresponding td cell in a column.

For example I need it this way.

<td data-title="Name" role="gridcell">Joe</td>

Any way I can achieve this ?

1 Answer, 1 is accepted

Sort by
0
Accepted
Dimiter Madjarov
Telerik team
answered on 23 Mar 2015, 08:40 AM

Hello Pantulu,

You could achieve this in the dataBound event of the Grid by iterating the cells and retrieve the title of the corresponding column.
E.g.

.Events(e => e.DataBound("dataBound"))

function dataBound(e) {
    var grid = e.sender;
    var columns = grid.columns;
    var cells = grid.tbody.find("tr[role='row'] td");
    var currentCell, title;
 
    for (var i = 0; i < cells.length; i++) {
        currentCell = $(cells[i]);
        title = columns[currentCell.index()].title;
        currentCell.attr("data-title", title);
    }
}

Regards,
Dimiter Madjarov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Grid
Asked by
Pantulu
Top achievements
Rank 1
Answers by
Dimiter Madjarov
Telerik team
Share this question
or