BoldSignEasily embed eSignatures in your .NET applications. Free sandbox with native SDK available.
<syncfusion:GridCheckBoxColumn MappingName="IsChecked" >
<syncfusion:GridCheckBoxColumn.CellStyle>
<Style TargetType="syncfusion:GridCell">
<Setter Property="utils:SetterValueBindingHelper.PropertyBinding">
<Setter.Value>
<utils:SetterValueBindingHelper Property="IsEnabled" Binding="{Binding Converter={StaticResource converter}}"/>
</Setter.Value>
</Setter>
</Style>
</syncfusion:GridCheckBoxColumn.CellStyle>
</syncfusion:GridCheckBoxColumn>
public class customconverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, string language)
{
return (value as UserInfo).IsChecked;
}
public object ConvertBack(object value, Type targetType, object parameter, string language)
{
return (value as UserInfo).IsChecked;
}
} |
Hi Jai Ganesh,
I want the same solution in UWP sfdatagrid. Based on some condition I have to disable some items and let few items enabled. Even though in ObservableCollection I'm disabling few of them but the NotifyPropertyChanged isn't firing. Only upon scrolling the collection is getting updated in the grid.
<Application.Resources>
<local:SelectorClass x:Key="styleSelector"/>
<Style x:Key="disableCell" TargetType="syncfusion:GridCell">
<Setter Property="IsEnabled" Value="True" />
</Style>
<Style x:Key="enableCell" TargetType="syncfusion:GridCell">
<Setter Property="IsEnabled" Value="False" />
</Style>
</Application.Resources>
<syncfusion:SfDataGrid x:Name="sfGrid"
Grid.Row="1"
ColumnSizer="Star"
AllowEditing="True"
AutoGenerateColumns="False"
GridValidationMode="InView"
CellStyleSelector="{StaticResource styleSelector}"
LiveDataUpdateMode="AllowDataShaping"
ItemsSource="{Binding UserDetails}"
ShowRowHeader="True"/> |
this.sfGrid.CurrentCellEndEdit += OnCurrentCellEndEdit;
private void OnCurrentCellEndEdit(object sender, CurrentCellEndEditEventArgs e)
{
//Change the CellStyle at runtime by update the value changed row index in SfDataGrid
this.sfGrid.UpdateDataRow(e.RowColumnIndex.RowIndex);
} |
public class SelectorClass : StyleSelector
{
protected override Style SelectStyleCore(object item, DependencyObject container)
{
var data = item as UserInfo;
//here customize based on your scenario
if (data != null && ((container as GridCell).ColumnBase.GridColumn.MappingName == "IsChecked"))
{
//custom condition is checked based on data.
if (data.UserId > 10005)
return App.Current.Resources["disableCell"] as Style;
return App.Current.Resources["enableCell"] as Style;
}
return base.SelectStyleCore(item, container);
}
} |