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

Conditonal detail template according to master row data

3 Answers 312 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Xavier
Top achievements
Rank 1
Xavier asked on 10 Oct 2013, 09:42 AM
Hi,
Here is what i want to achieve : 
I have a grid wich contains a list of customers (for instance). I have a template specificied using  ClientDetailTemplateId which contains a TabStrip. One of the tabs contains another grid which display orders. Preety much the same as the example in the demos : http://demos.kendoui.com/web/grid/detailtemplate.html
I need to show/hide columns of that order grid according to to the type of customer, how can I achieve that ?

3 Answers, 1 is accepted

Sort by
0
Dimiter Madjarov
Telerik team
answered on 11 Oct 2013, 03:08 PM
Hello Xavier,


To achieve this I would suggest you to bind to the dataBound event of the child grid. In the event handler you could retrieve the model for the master row, check the customer type and show/hide the columns if required.
E.g.
function dataBound(e) {
    var masterRow = this.wrapper.closest("tr.k-detail-row").prev(".k-master-row");
    var masterGrid = $("#grid").data("kendoGrid");
 
    var masterDataItem = masterGrid.dataItem(masterRow);
 
    if (<condition>) {
        this.hideColumn(0);
    }
}

I hope that this was the information that you were looking for. I wish you a great day!

 

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
Xavier
Top achievements
Rank 1
answered on 15 Oct 2013, 01:35 PM
Thanks for you answer Dimiter,

I can access the master data item with your code which is great, however the hideColumn method does not work. Is does not crash either but the column remains visible, any idea ?
0
Dimiter Madjarov
Telerik team
answered on 15 Oct 2013, 02:26 PM
Hello Xavier,


I could not be sure what is the reason for the strange behavior. Please share some sample code of the exact implementation, so I could assist you further.

 

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
Xavier
Top achievements
Rank 1
Answers by
Dimiter Madjarov
Telerik team
Xavier
Top achievements
Rank 1
Share this question
or