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

Hide GridViewCheckBoxColumn cells of few rows based on condition

2 Answers 262 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Manishkumar
Top achievements
Rank 1
Manishkumar asked on 15 Sep 2011, 11:17 AM
I am using a GridViewCheckBoxColumn. My requirement is i will hide the checkbox in each row if binded value lavel is 6. I had used one Cell Style Selector. If i make the visibility=Collapsed then the cell as well as cell border is also not displayed and looking odd. Please help me how i will be able to collapse few cells based on above condition with the only checkbox collapsed and border remain as it is


public

 

class CustomVisibilityStyle : StyleSelector

 

{

 

public override Style SelectStyle(object item, DependencyObject container)

 

{

 

PeopleDataDC ppl = item as PeopleDataDC;

 

 

if (ppl.Level == 6)

 

{

 

return VisibleStyle;

 

}

 

else

 

{

//((System.Windows.Controls.

ContentPresenter)(((System.Windows.Controls.Grid)(((Telerik.Windows.Controls.GridView.GridViewCell)(container)).Template.LoadContent())).Children[7])).Visibility = Visibility.Collapsed;

 

 


return
CollapsedStyle;

 

}

 

return CollapsedStyle;

 

}

 

public Style VisibleStyle { get; set; }

 

 

public Style CollapsedStyle { get; set; }

 

}

2 Answers, 1 is accepted

Sort by
0
Pavel Pavlov
Telerik team
answered on 20 Sep 2011, 02:33 PM
Hello Manishkumar,

For this you will need to work with the visibility of the checkbox itself. Not the Entire cell.

For this , you will need to do the following :

1. Handle the RowLoaded event .
2. Inside the event handle find the checkbox. For this you may use the ChildrenOfType<> extension method ( namespace: Telerik.Windows.Controls) .
3. After you have a reference to the checkbox - bind its visibility to your"level" property.
*Since your level property is not od type VIsibility , you may need to use an IValueConverter for the binding.

If all this sounds complicated or you find any troubles implementing it , just let me know.

Best wishes,
Pavel Pavlov
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Marc
Top achievements
Rank 1
answered on 21 Sep 2011, 08:38 PM
Couldn't you just use:

<Telerik:GridViewDataColumn.CellStyle>
    <Style TargetType="Telerik:GridViewCell">
        <Setter Property="Visibility"
                Value="{Binding RemoteScanEnabled, Converter={StaticResource boolToVisibility}}" />
    </Style>
</Telerik:GridViewDataColumn.CellStyle>
Tags
GridView
Asked by
Manishkumar
Top achievements
Rank 1
Answers by
Pavel Pavlov
Telerik team
Marc
Top achievements
Rank 1
Share this question
or