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;
}
}