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

Hide/Show Column of Detail Grid

3 Answers 234 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Arun
Top achievements
Rank 1
Arun asked on 02 Feb 2014, 08:47 PM
Hi,

I currently have a Master Grid and a Detail Grid. I am trying to show/hide columns based on user selection which is stored in the database.
For example:
Master Grid : Col1,Col2,Col3
Detail Grid: ColA,ColB,ColC,ColD,ColF
Now, i retrieve col names from the database. On DataBound event of the detail grid i have a function call which 
loops thru the data and calls hideColumn() and it works for the first detail grid of the first master row.
but when expanding the second row of the master the detail grid does not hide any columns.
Please help.

var grid = $("#childgrid").data("kendoGrid");
            if (grid != undefined) {
                for (var i = 0; i < view.length; i++) {
                    var columnName = view[i]["FieldName"];
                    var selected = view[i]["Selected"]
                    if (selected == true) {
                        grid.showColumn(columnName);
                    } else {
                        grid.hideColumn(columnName);
                    }
                }
            }









3 Answers, 1 is accepted

Sort by
0
Dimiter Madjarov
Telerik team
answered on 03 Feb 2014, 08:38 AM
Hello Arun,


From the provided information I could not be sure what is the exact reason for the problem. A possible issue could be if the child grids does not have a unique name, which will cause initialization problems.

If possible, could you please provide a small isolated example, where the issue is reproducing, so I could inspect it locally and assist you further?

I am looking forward to hearing from you.

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
Arun
Top achievements
Rank 1
answered on 03 Feb 2014, 02:00 PM
Dimiter,

Thanks for the Response. All I am trying to do is hide/show certain columns from the detail grid on expanding.
I have the list of columns setup where users can select which columns needs to shown. on detailExpand event: I am able to access the Detail grid columns like this - i have attached file. (unable to attach a text of 2kb)
var tablerow = $('#childgrid .k-grid-header .k-header ');
i have access to table cell header and was able remove the tablerow[1].remove
but for cell content , I am not able to remove.

0
Dimiter Madjarov
Telerik team
answered on 04 Feb 2014, 11:54 AM
Hello Arun,


Please excuse me, but I am not sure that I completely understand the current scenario. In the first post you are referring to using the dataBound event of the child Grid and the hideColumn / showColumn methods. Now you refer to the detailExpand event and hiding the header row and cell contents.

Could you please elaborate a bit more and provide a more detailed sample code, so I could be more helpful?

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