Posted 18 January 2021, 10:08 pm EST
Hi, using the flexgrid
is it possible use the same ConverterCulture setting used in the columns
for the grouprows
StringFormat=‘N2’, ConverterCulture={x:Static glob:CultureInfo.CurrentCulture}}
Thanx
Forums Home / ComponentOne / WPF Edition
Posted by: kisar on 18 January 2021, 10:08 pm EST
Posted 18 January 2021, 10:08 pm EST
Hi, using the flexgrid
is it possible use the same ConverterCulture setting used in the columns
for the grouprows
StringFormat=‘N2’, ConverterCulture={x:Static glob:CultureInfo.CurrentCulture}}
Thanx
Posted 20 January 2021, 7:23 pm EST
Hi Kisar,
Do you want to set the converter culture for the GroupHeader or GroupAggregate? In case it is GroupHeader then you can use FlexGrid’s GroupHeaderConverter property as follows:
public class GroupHeaderConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
var col = value as CollectionViewGroup;
return $"{col.Name}, {col.ItemCount.ToString("N2", CultureInfo.CurrentCulture)}"; // returning content displayed in group header
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
// Usage
flexGrid.GroupHeaderConverter = new GroupHeaderConverter();
JFYI, GroupAggregates by default uses the same settings specified for the Column.
Regards,
Kartik
Posted 20 January 2021, 9:05 pm EST
Hi, i meant GroupAggregates but it does not work for me,
i attached a screenshot where you can see the difference.
In the xml :
<c1:Column Width=“100” Binding=“{Binding krecord_base.kdisplay_amount_invoice, StringFormat=‘N2’, ConverterCulture={x:Static glob:CultureInfo.CurrentCulture}}” GroupAggregate=“Sum”>
In the code :
var gr = new C1.WPF.FlexGrid.GroupRow();
gr.Background =System.Windows.Media.Brushes.LightGray;
gr.FontSize =KAppResources.ksystem__font_size__minus02;
flexgrid.ColumnFooters.Height =18; flexgrid.ColumnFooters.Background =System.Windows.Media.Brushes.Black; flexgrid.ColumnFooters.Margin =new System.Windows.Thickness(2,2,0,2); flexgrid.ColumnFooters.Rows.Add(gr);
Thanx
Posted 21 January 2021, 7:17 pm EST
Hi Kisar,
Thank you for sharing the sample code.
I am able to reproduce this behavior at my end. This seems like a bug so I have escalated it to the devs and will revert back to you when there is any update. [Internal Tracking Id - C1XAML-26843]
However, until then you can override the GroupRow’s GetDataFormatted method as workaround as follows:
public class GroupRowEx : GroupRow
{
public override string GetDataFormatted(Column col)
{
var data = base.GetDataRaw(col);
return string.Format(col.Binding.ConverterCulture, "{0:"+ col.Binding.StringFormat +"}", data);
}
}
// Usage
var gr = new GroupRowEx();
flexGrid.ColumnFooters.Rows.Add(gr);
Regards,
Kartik
Posted 22 January 2021, 12:21 am EST
Thanx,
i have one more question about GroupAggregates,
if i delete one or more row it does not update the “sum” or “count” or…
is there something can allow to update it?
Posted 24 January 2021, 4:45 pm EST
Hi Kisar,
It seems like you are removing rows using the FlexGrid.Row’s Remove/RemoveAt methods which only removes the rows from the UI and not from the underlying source. Therefore, you have to use FlexGrid CollectionView’s Remove/RemoveAt method for removing rows from FlexGrid as follows:
(flexGrid.CollectionView as ListCollectionView).RemoveAt(1);
Regards,
Kartik
Posted 24 January 2021, 7:40 pm EST
HI,
in my case i delete the records from viewmodel
Thanx
Posted 26 January 2021, 6:30 pm EST
Hi Kisar,
Are you using a List as FlexGrid’s ItemsSource? FYI, list doesn’t provide any notification when any item is added/removed. Therefore, I would recommend you to use an ObservableCollection instead or you can use any collection which implements INotifyCollectionChanged interface.
In case if this doesn’t resolves your issue then I would like to request a small sample application replicating this behavior along with the C1 version you are using.
Regards,
Kartik