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

Optional detail template

3 Answers 133 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Gary
Top achievements
Rank 1
Gary asked on 30 Oct 2013, 02:39 PM
It seems that the detail template functionality is activated by the presence of an event handler for the detailInit event. My scenario requires that some rows have a detail template while others do not. I can make the determination whether a detail template is needed from withing detailInit, but I don't know how to use this information to optional disable the use of the template. Is this possible?

3 Answers, 1 is accepted

Sort by
0
Dimiter Madjarov
Telerik team
answered on 31 Oct 2013, 03:25 PM
Hi Gary,


If the data required to decide whether the detail template is needed or not is available only after the detailInit event is triggered, then the most that could be done would be to set it's content to an empty string.
E.g.
function detailInit(e) {
    e.detailRow.find(".k-detail-cell").text("");
}
OR 
you could bind to the detailExpand event instead and just collapse the expanded row.
E.g.
function detailExpand(e) {
    var that = this;
    var masterRow = e.masterRow;
 
    setTimeout(function () {
        that.collapseRow(masterRow);
    });
}

If the data is available, when the master Grid is bound (i.e. in the master model) you could bind to it's dataBound event and hide the expand icons for the rows, that don't require a detail template.
E.g.
$(".k-hierarchy-cell .k-icon").hide();

 

Regards,
Dimiter Madjarov
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Brian Vallelunga
Top achievements
Rank 1
answered on 20 Oct 2014, 05:55 PM
Assuming the data is known at the time of the master grid being bound, how would I differentiate the rows that should have the detail toggle hidden? I'd like to be able to add a class to each row indicating if the detail is available. I would think this would require an event such as RowDataBound, which doesn't exist.
0
Dimiter Madjarov
Telerik team
answered on 21 Oct 2014, 07:54 AM
Hello Brian,


You could use the dataBound event of the Grid, iterate the rows and add the class where required.
E.g.
function dataBound(e) {
    var grid = this;
 
    grid.table.find("tr[role='row']").each(function () {
        var model = grid.dataItem(this);
 
        if (<condition>) {
            $(this).addClass("myClass");
        }
    });
}

Regards,
Dimiter Madjarov
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
Gary
Top achievements
Rank 1
Answers by
Dimiter Madjarov
Telerik team
Brian Vallelunga
Top achievements
Rank 1
Share this question
or