|
Queries |
Answers | |
|
Query 1 :
Display ScrollBar on right if lines were greater than space. |
By default, SfDatagrid shows ScrollBar on right side, if the lines exceeds the available space. If you are facing any issue in this, Could you please share more details ? | |
|
Query 2:
the quantity ordered can be in the following two conditions: - Equal to Zero - Greater than zero if ordered products. |
To achieve this, you can use DataValidation to restrict quantity values to be not less than Zero.
Please find more details about DataValidation in SfDataGrid in below link
| |
|
Query 3:
In the case of products ordered I would like to see the value of the quantity in Bold, with foreground Blue and Yellow Backcolor. |
To achieve this, you can use GridColumn.CellStyleSelector. Please refer the below code snippet
Also please find the sample in below link,
Also please find the below KB links for more details,
|
|
<local:CellStyleConverter x:Key="cellStyleConverter"/>
<syncfusion:GridTextColumn MappingName="Symbol" TextAlignment="Left" >
<syncfusion:GridTextColumn.CellStyle>
<Style TargetType="syncfusion:GridCell">
<!--Below code is for applying style using Triggers-->
<Style.Triggers>
<DataTrigger Binding="{Binding Path=Change,
Converter={StaticResource cellStyleConverter}}"
Value="True" >
<Setter Property="FontWeight" Value="Bold"/>
<Setter Property="Foreground" Value="Blue"/>
<Setter Property="Background" Value="Yellow"/>
</DataTrigger>
</Style.Triggers>
</Style>
</syncfusion:GridTextColumn.CellStyle>
</syncfusion:GridTextColumn>
public class CellStyleConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
var changeValue = double.Parse(value.ToString()) >= 0;
return changeValue;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
} |
|
public class FontStyleConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (double.Parse(value.ToString()) >= 0)
return FontWeights.Bold;
return FontWeights.Normal;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
public class ForegroundConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (double.Parse(value.ToString()) >= 0)
return new SolidColorBrush(Colors.Blue);
return new SolidColorBrush(Colors.Black);
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
public class BackgroundConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (double.Parse(value.ToString()) >= 0)
return new SolidColorBrush(Colors.Yellow);
return new SolidColorBrush(Colors.Transparent);
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
<syncfusion:GridTextColumn MappingName="Symbol" TextAlignment="Left" >
<syncfusion:GridTextColumn.CellStyle>
<Style TargetType="syncfusion:GridCell">
<!--Below code is for applying style using converters-->
<Setter Property="FontWeight" Value="{Binding Change,
Converter={StaticResource fontStyleConverter}}" />
<Setter Property="Foreground" Value="{Binding Change,
Converter={StaticResource foreGroundConverter}}" />
<Setter Property="Background" Value="{Binding Change,
Converter={StaticResource backGroundConverter}}" />
</Style>
</syncfusion:GridTextColumn.CellStyle>
</syncfusion:GridTextColumn> |