[英]jquery selector to find a kendo grid column and format
I'm trying to apply formatting to a column in my kendo grid on the DataBound Event. 我正在尝试将格式应用于DataBound事件上的kendo网格中的列。 The DataBound event throws a javascript function where i'm trying to select a column and apply some Date formatting.
DataBound事件抛出一个javascript函数,我试图选择一个列并应用一些日期格式。 The bound column looks like this:
绑定列如下所示:
columns.Bound(c => c.CreatedDate).Title("Submitted on").Filterable(ftb => ftb.Cell(cell => cell.Operator("contains"))).Format("{0: MM/dd/yyyy HH.mm.ss}");
The reason i need to do it there is because i have a button that filters the grid, and upon refreshing the data in the grid it loses the formatting on the date. 我之所以需要这样做的原因是因为我有一个过滤网格的按钮,并且在刷新网格中的数据时它会丢失日期的格式。 The current code i have is:
我目前的代码是:
function onDataBound(e) {
var grid = $("#MyGrid").data("kendoGrid");
grid.tbody.find('td').each(function () {
var dataItem = grid.dataItem(this);
if (dataItem.CreatedDate) {
$(this).DoTheFormatting
}
});
Need help with the jquery selector 需要有关jquery选择器的帮助
You can iterate over the e.sender.tbody.children()
, and use the get
function to retrieve your columns data instead of using magic numbers on column indexes, like so: 您可以迭代
e.sender.tbody.children()
,并使用get
函数检索列数据,而不是在列索引上使用幻数,如下所示:
var rows = e.sender.tbody.children();
for (var j = 0; j < rows.length; j++)
{
var row = $(rows[j]);
var dataItem = e.sender.dataItem(row);
if (dataItem.get("CreatedDate"))
{
$(this).DoTheFormatting...
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.