lightswitch C1FlexGrid 分组列头自定义标题处理

自动的分组默认显示 不符合用户要求,同时有英文 如(3 Items) , 主要对GroupHeaderConverter  进行了处理。

public partial class FlexibleProductsGrid
{
    partial void FlexibleProductsGrid_Created()
    {
        // Write your code here.
        IContentItemProxy _proxy = this.FindControl("C1FlexGrid");
        _proxy.ControlAvailable += _proxy_ControlAvailable;
    }

    void _proxy_ControlAvailable(object sender, ControlAvailableEventArgs e)
    {
            var flex = e.Control as C1FlexGrid;
            flex.LoadedRows += (s, eaflex_LoadedRows) =>
            { flex.GroupHeaderConverter = new MyGroupCellConverter(); };

    }
}
public class MyGroupCellConverter : IValueConverter
{
    public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
    {
        var gr = parameter as GroupRow;
        var group = gr.Group;
        var grp = ((gr.Grid.CollectionView.GroupDescriptions[gr.Level]) as PropertyGroupDescription);

        string desc = ((gr.Grid.CollectionView.GroupDescriptions[gr.Level]) as PropertyGroupDescription).PropertyName;

        if (desc == "SupplierName") //此处根据需求自行改更,判断数据项KEY
            {
                return string.Format("{0} -> {1} ({2}个采购合同)", "供应单位", group.Name, group.Items.Count);
            }
            else
            {
                return string.Format("{0} -> {1} ({2}个采购项)", "采购合同", group.Name, group.Items.Count);
            }

    }

    public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
    {
        return null;
    }
}



你可能感兴趣的:(LightSwitch)