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

Radgrid with Hierarchy - Only for specific type

3 Answers 52 Views
Grid
This is a migrated thread and some comments may be shown as answers.
MathieuB
Top achievements
Rank 1
MathieuB asked on 06 Mar 2019, 02:39 PM

Hello,
I use a RadGrid with a hierarchy system. I have 3 types of resources for my line (human, location, equipment) in my grid. But I only can  add a child if the resource type is a location.

I need to "disable or hide" the Expand/Hierarchy column, but I dont this attribute on the dataItem. 

How can I  "disable or hide" the Expand/Hierarchy column ONLY for "human and equipment" ?

Thank you :) 

 

I attach a files for explain what I have currently (left image) and the result that I hope to get (right)

 

3 Answers, 1 is accepted

Sort by
0
Attila Antal
Telerik team
answered on 11 Mar 2019, 08:03 AM
Hi Mathieu,

To hide the expand/collapse columns, you can try the approach described in the hide group expand collapse columns in RadGrid forum thread.

If you only want to hide the expand buttons for specific items/or items that do not have children, you can try the following two approaches, one of which is the server-side approach described in the Hiding the expand/collapse images when no records article.  You can also implement this on client like the example below. 

<script type="text/javascript">
    function gridCreated(sender, args) {
        var dataItems = sender.get_masterTableView().get_dataItems(); // get the collection of grid rows (dataItems)
        for (var i = 0; i < dataItems.length; i++) { // loop throug the rows
            if (!hasDetailRows(dataItems[i])) // method to check whether the rows have detail tables that has any records
                $("#" + dataItems[i].get_id()).find(".rgExpand").hide(); // hide the expand button
        }
    }
    // method that takes grid row (dataItem) as parameter
    function hasDetailRows(dataItem) {
        for (var i = 0; i < dataItem.get_nestedViews().length; i++) { // loop through all detailTables inside the item
            if (dataItem.get_nestedViews()[i].get_dataItems().length > 0) { // check whether the detailTable has rows
                return true;
            }
        }
        return false;
    }
</script>

Kind regards,
Attila Antal
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
MathieuB
Top achievements
Rank 1
answered on 18 Mar 2019, 12:13 PM
Hi Attila,

              Yes it's the solution that I have been choice after more searching.

Thank you for you're help
0
Attila Antal
Telerik team
answered on 21 Mar 2019, 07:46 AM
Hi Mathieu,

I am glad the see the issue has been sorted out. Please, let us know if you have any questions.

Good luck with your project!

Kind Regards,
Attila Antal
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
Grid
Asked by
MathieuB
Top achievements
Rank 1
Answers by
Attila Antal
Telerik team
MathieuB
Top achievements
Rank 1
Share this question
or