I want to bind a column to a value at a particular index in a List or a particular key in a Dictionary. The values display properly in the grid however when I attempt to sort by that particular column the grid stops responding. I pasted some sample code that reproduces the problem. This grid will build and display correctly but once sorted by either the C3 or C4 column it will not sort and also clicking on the C1 and C2 column headers will no longer work.
class TestData
{
public string C1 { get; set; }
public decimal C2 { get; set; }
public List<int> C3 { get; set; }
public Dictionary<string, int> C4 { get; set; }
}
void BuildGrid(SfDataGrid grid)
{
grid.AllowSorting = true;
grid.Columns.Add(new GridTextColumn()
{
HeaderText = "C1",
MappingName = "C1",
AllowSorting = true,
AllowResizing = true
});
grid.Columns.Add(new GridNumericColumn()
{
HeaderText = "C2",
MappingName = "C2",
AllowSorting = true,
AllowResizing = true
});
grid.Columns.Add(new GridNumericColumn()
{
HeaderText = "C3",
MappingName = "C3[0]",
AllowSorting = true,
AllowResizing = true
});
grid.Columns.Add(new GridNumericColumn()
{
HeaderText = "C4",
MappingName = "C4[C4]",
AllowSorting = true,
AllowResizing = true
});
var data = new List<TestData>
{
new TestData
{
C1 = "1",
C2 = 1M,
C3 = new List<int> { 1, 11, 111 },
C4 = new Dictionary<string, int> { { "C4", 1 } }
},
new TestData
{
C1 = "2",
C2 = 2M,
C3 = new List<int> { 2, 22, 222 },
C4 = new Dictionary<string, int> { { "C4", 2 } }
}
};
grid.ItemsSource = data;
}
Is there anything that I am missing here that might be causing the grid to behave this way?
Thanks