column header are not visible in XamDataGrid when record count=0 and AutoGenerateFields is True. I want to display the column header in this case. Is it possible?
Not that I'm aware of. It does look wierd, to have an empty space, huh? I've done two things to solve this:
1. Collapse the grid when it's empty.
2. Manually generate the column headers, which I always do now, anyway.
OK, this is gold, but I can't seem to find out how to manually generate the column headers. Could you please point me in the right direction tbeaulieu?
Just define FieldLayouts. There are lots of examples of this here!
But ... here is a simple one:
<igDP:XamDataGrid.FieldLayouts>
<igDP:FieldLayout Key="DrugEp">
<igDP:FieldLayout.Fields>
<igDP:Field Name="Ep" Label="EP Value" /> <igDP:Field Name="MinDosage" Label="Min Dose" Converter="{StaticResource nullableDecimalConverter}" /> <igDP:Field Name="MaxDosage" Label="Max Dose" Converter="{StaticResource nullableDecimalConverter}" /> <igDP:Field Name="IsActive" Label="Active" />
</igDP:FieldLayout.Fields>
</igDP:FieldLayout>
</igDP:XamDataGrid.FieldLayouts>
Ah, ok...
I am doing what you described, but I use a couple of field layouts (one has a field which spans several columns and thus it has hidden labels). I'm manually assigning the field layouts in my AssigningFieldLayoutToItem code-behind event handler based on the underlying data of the record.
The problem is depending on the order of the records, the layout with the spanning columns (hidden labels) may come first which means the headers will not display on top -they will show above the first record that has a field layout with a visible label. I realize this sounds completely crazy, but this is my task. Plus, I'm about 1 week into the XamDataGrid.
I thought you might have an even more manual way to stick 1 header on top no matter what (even with multiple field layouts).
Thanks anyway!
-Mark
That is an interesting scenario.
I tried a number of approaches and got nowhere, really. The closest I was able to come was to get one header to appear with the first row under it, the "desired" header to appear and then the rest of the data.
From what I can tell, the grid isn't going to let you do this, but honestly, this is a case for an expert to show us the light ... if there is one!
Anyone? Anyone? Bueller?