[英]Kendo ui grid expand detailini row after refreshing the grid
I know this question has been posted a few times, and i´ve been reading about those solutions, but i need some help figuring out what am i missing.我知道这个问题已经发布了几次,我一直在阅读这些解决方案,但我需要一些帮助来弄清楚我错过了什么。
What i want is the master grid to expand the last expanded row after a READ call, so i´ve read this and also this but nothing seems to work, my code is this:我想要的是主网格在 READ 调用后扩展最后展开的行,所以我已经阅读了这个和这个,但似乎没有任何效果,我的代码是这样的:
detailExpand: function (e)
{
var grid = $("#gridTimesheets").data("kendoGrid");
expandedRowUid = e.masterRow.data('uid');
}
then on my master databound function i have this:然后在我的主数据绑定功能上,我有这个:
dataBound: function(e)
{
this.expandRow($('tr[data-uid=' + expandedRowUid + ']'));
}
the only thing that seems to expand the rows after the refresh is this:刷新后似乎扩展行的唯一事情是:
this.expandRow(this.tbody.find("tr.k-master-row"));
but it expands all rows, i want only the last row before the READ method.但它扩展了所有行,我只想要 READ 方法之前的最后一行。
What am i missing here?我在这里缺少什么?
Note that anytime data is rendered, all uid s are re-created. 请注意,无论何时呈现数据,都将重新创建所有uid 。 So you can't store an old uid, because it will be lost. 因此,您无法存储旧的 uid,因为它将丢失。 I suggest you to store the row index: 我建议您存储行索引:
detailInit: function(e) {
$(e.detailCell).text("inner content");
lastRowIndex = $(e.masterRow).index(".k-master-row");
}
Then find the row by index inside the dataBound
: 然后在dataBound
按索引查找行:
dataBound: function() {
var row = $(this.tbody).find("tr.k-master-row:eq(" + lastRowIndex + ")");
this.expandRow(row);
}
Add javascript function to expand button on DataBound function添加 javascript 函数以在 DataBound 函数上展开按钮
function dataBound() {
this.tbody.find("tr.k-master-row td a.k-i-expand").attr('onclick','SetWidthOnExpand()')
}
function SetWidthOnExpand() {
setTimeout(function () {
$('.k-header').removeAttr('style');
$('.k-selectable tbody tr td').removeAttr('style');
},1000)
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.