Ok, so I am opening a new topic with this issue
Hi, I am MarkoI am having a problem understanding how this works:http://samples.infragistics.com/sllob/RunSamples.aspx?cn=grid#/grid/handling-hierarchical-data-setsCan someone please put here some sample project with Access database (I am using SQL 2008) so that I can see how do I get data from the database into the class objects and the into grid. I am asking this cause I can't understand this part with binding data to the columns:Text="{Binding Source={StaticResource Strings} , Path=XWG_OrderDetails_Discount}"This is how I load data into grid from database: I make new class "Users" and make method in service "GetUsers" that executes sql query and gets data from db onto list of objects of "Users" class and returns that list. When execution of the service method is completed I do this xamGrid1.ItemsSource = e.Result; and grid displays data.How is this "http://samples.infragistics.com/sllob/RunSamples.aspx?cn=grid#/grid/handling-hierarchical-data-sets" different ? comparing to the my method described above??
PS. Can someone please put here some sample project with Access database.
Please help me resolve this issue,Best regards,Marko
Hello,
I have been looking into the sample provided and compared to your scenario the two implementations does basically the same, but the Infragistics sample performs the action via binding from the xaml.
To be more specific, you set the xamGrid’s ItemsSource in the code behind. I am not sure what e.Result is, but I assume that this is the output from the service that provides the data. You mentioned that you have collection of Users that are loaded with data retrieved from the db. Let say that you have a Name property in this User class and you have filled it with a data. In case you have a textBox, like in the Infragistics sample, that you wish to fill with this name, you can do this in two different ways:
From the code behind:
myText.Text = User.Name;
or bind it from the xaml:
xmlns:local="clr-namespace:MySamle" //reference to the codehind
.
<Grid.Resources>
<local:User x:Key="UsrData"/> // we get the class
</Grid.Resources>
<Text="{Binding Source={StaticResource UsrData } , Path= Name }" // and bind to the needed property
What happens in the sample is pretty much the same and it is possible to Grid’s ItemsSource from the xaml. Notice that you probably should implement the INotifyPropertyChanged interface, in order to have your TextBox updated according to its corresponding data source. For more information on the mentioned interface, please visit:
http://msdn.microsoft.com/en-us/library/ms743695.aspx
Please do not hesitate to ask any question regarding the original discussed topic .
Sincerely,
Ekaterina
Developer Support Engineer
Infragistics, Inc.
www.infragistics.com/support
Hello
EkStaneva thank you very much for your answer ,now I understand the concept of binding data from the xaml code.
I still have the problem of understanding the concept of "ColumnLayout columns" tough. And I don't get how do I bind data into those columns because that kind of columns can also have their own "ColumnLayout columns"
On this example page:http://samples.infragistics.com/sllob/RunSamples.aspx?cn=grid#/grid/handling-hierarchical-data-sets there is:
<navigation:Page.Resources> <res:GridStrings x:Key="Strings" /> </navigation:Page.Resources>
So I guess there is an object "GridStrings" somewhere on code behind. I can't possibly visualize how this object looks like (his definition) cause one customer has his orders, every order has it's details (it is hierarchical). It is not as simple as Users object from the previous post. That is why I asked if you or someone else could make an example project and post it here cause I can't find one on this site.
Please help I didn't resolved this issue yet.
Best regards,
Marko.
Hello Marko,
Thank you for your answer, I am glad that my explanations were helpful to you.
As to your question, I have created the sample project that you have requested.
In general, the columnLayout is used to explicitly define the layout for every inner level of your hierarchal data source. That is useful when we want to customize the way that the nested object data is being visualized by the grid. As you will see in my sample, I have created a very simple hierarchal data which contains one object A, that is nested in object B and in object C I am creating a list of B objects (and B contains a list of A objects). So in my grid I have two columns on the first level – these are columns that corresponds to the properties of object B. However my B object has a property that return a Collection of A objects and if I do not explicitly specify a ColumnLayout, the grid would not know how to visualize the data from the A object. Notice that in order to apply this behavior you should set the AutoGenerateColumns to False, because otherwise the grid will handle the columns arrangement for you. In case you do not want to explicitly customize the look and feel of your columns you can take advantage of this automatic arrangement, but as far as I understood you would like to use some template in order to customize your columns, so using a self-defined layout is a good idea.
Please let me know if you require any further assistance regarding the discussed matter.
Infragistics, Inc .
Hi,
Thanks for that sample project - it really helped a lot
I have managed to reproduce your code in my project and now I have child rows, but this raised couple of other issues and doubts.
1st: In declaration of OuterObject from your sample "InnerInfo" is declared as a List of objects
public class MyOuterObjectModel { public List<MyInnerObjectModel> InnerInfo { get; set; } public string Products { get; set; } public string Description { get; set; } }
Can I declare "InnerInfo" as a simple one object like so:
public MyInnerObjectModel InnerInfo { get; set; } // ??? Cause I will have only one inner row (child row) for every outer row (parent row)
2nd: How do I control height of that column with the arrows (Expander Indicator I believe?) Cause if I define my rows to be 20px heigh it creates a gap between rows - I believe because of that first column with expander arrows. Height of those arrow cells remains the same - bigger than 20px. See that gap in the pic:
3rd: Can I somehow remove this sub row header "Komentar" (from pic), that way parent row would act as a header for sub row ?? It would be much more elegant for my web app. Cause parent rows hold the title and child rows hold large text (for example email subject and email body).
3rd RESOLVED - I have used HeaderVisibility property like so:
<ig:ColumnLayout Key="InnerInfo" HeaderVisibility="Collapsed"> and columnlayout header is gone.
Thank you for your post.
I was looking into your questions and :
1) In order to have one row in your second layout you can have a list with one element inside.
2) To manipulate the expansion indicator height you can set a style like that:
xmlns:Prim="clr-namespace:Infragistics.Controls.Grids.Primitives;assembly=InfragisticsWPF4.Controls.Grids.XamGrid.v11.2"
…
<ig:XamGrid.ExpansionIndicatorSettings>
<ig:ExpansionIndicatorSettings>
<ig:ExpansionIndicatorSettings.Style>
<Style TargetType="{x:Type Prim:ExpansionIndicatorCellControl}">
<Setter Property="Height" Value="50"/>
</Style>
</ig:ExpansionIndicatorSettings.Style>
</ig:ExpansionIndicatorSettings>
</ig:XamGrid.ExpansionIndicatorSettings>
3) To hide the layout header there is a property called HeaderVisibility. You can set it like that:
<ig:ColumnLayout Key="InnerInfo" HeaderVisibility="Hidden">
Please let me know if you require additional assistance regarding the discussed matter.
Hi.
Thanks for your post it helped a lot, I have resolverd issues 1) and 3), now about that expansion indicator cell height I got an error:
"Error 8 The type 'x:Type' was not found. Verify that you are not missing an assembly reference and that all referenced assemblies have been built."
Here is what I wrote:
xmlns:Prim="clr-namespace:Infragistics.Controls.Grids.Primitives;
assembly=InfragisticsSL4.Controls.Grids.XamGrid.v10.3"
Please note that I am building a Web Silverlight application (Silverlight hosted on asp.net web project). So my dilemma is this: Can I write like you did: Infragistics.Controls.Grids.Primitives;
assembly=InfragisticsWPF4.Controls.Grids.XamGrid.v11
( WPF4 or SL4 that's the dilemma, does this matter at all?)
BTW. In your post I couldn't see the entire line so I don't know if I wrote it correctly. (here is what I see in your post: xmlns:Prim="clr-namespace:Infragistics.Controls.Grids.Primitives;assembly=InfragisticsWPF4.Controls.G... and this is the end)
Regards,
Please remove the x:Type and the curly braces like that:
<Style TargetType="Prim:ExpansionIndicatorCellControl" … >
Please let me know if you require further assistance regarding the discussed matter.
Hello ,
I am just checking if you require any further assistance on the matter.
Infragistics
Hi Marko,
I am glad I was able to assist you.
As to your last questions, I took a look and there is a gap in the 3ird row because, as I mentioned, my code reaches only the second level of the hierarchy. In order to manipulate the third one, you can nest additional loop like this:
foreach (Row r in xamGrid1.Rows)
{
if (r.Control.Height != 14)
r.Control.Height = 14;
if (r.HasChildren)
foreach (var c in r.ChildBands)
foreach (Row row in c.Rows)
if (row.Control != null && row.Control.Height != 14)
row.Control.Height = 14;
foreach (var v in row.ChildBands)
foreach (Row row2 in v.Rows)
if (row2.Control != null && row2.Control.Height != 14)
row2.Control.Height = 14;
}
Or you can organize this in a recursion structure, so no nesting will be necessary in future, if you decide to add more levels in your hierarchy.
As to your second question, every column layout can declare its own expansion indicator’s style - all you have to do is to define ExpansionIndicatorSettings on the desired level. Please notice that you should use ExpansionIndicatorSettingsOverridel like this:
<ig:ColumnLayout.ExpansionIndicatorSettings>
<ig:ExpansionIndicatorSettingsOverride>
<ig:ExpansionIndicatorSettingsOverride.Style>
<Style TargetType="Prim:ExpansionIndicatorCellControl">
<Setter Property="Height" Value="20"/>
<Setter Property="Background" Value="Violet"/>
</ig:ExpansionIndicatorSettingsOverride.Style>
</ig:ExpansionIndicatorSettingsOverride>
</ig:ColumnLayout.ExpansionIndicatorSettings>
<ig:ColumnLayout.Columns> …
Please let me know if you have any additional questions regarding the discussed matter.
Hi EkStaneva
Your solution works fine. Thank you very much for your help.
I have two more doubts but they are not so impostant, I am just gonna ask you if you know to solve them of the top of your head. Here is the picture:
1st one: Can you see the gap still exists only (i repeat only) after the first sub row "Opis problema"? How do I remove it?
2nd one: Can expansion indicator cell have two different styles?? One style on ordinary (parent) row and second style on sub row. I am asking this because I have set padding so that the arrow would be nicely visible on sub row expansion indicator cells where height of the cell is 15px. But that style
<Setter Property="Padding" Value="0 -2 0 0" /> <-- note !! <Setter Property="Margin" Value="0" /> <Setter Property="HorizontalAlignment" Value="Center" /> <Setter Property="HorizontalContentAlignment" Value="Center" /> <Setter Property="VerticalAlignment" Value="Top" /> <Setter Property="VerticalContentAlignment" Value="Top" /> <Setter Property="Width" Value="30" />
applies on expansion indicator cells of parent rows too where height of the row is 26px so the arrow goes up. And is not vertically centered to "Center". It just doesn't look nice.
These ARE minor issues but I would like to solve them nevertheless.
Best regards.
thank you for your answer, I will try it and then I'll get back to you.
I have been investigating into your issue and you can use the following code in order to set the height of the xamGrid’s main layout and second layout rows separately:
private void xamGrid1_LayoutUpdated(object sender, EventArgs e)
Please notice that the inner instance of the row.Control will be instantiated when the corresponding layout gets expanded, which means that the height property should be set when the layout is being updated. That’s why I am placing this code in the LayoutUpdated handler. Notice also the check which I am performing (if value is 14) – this one is done in order to guarantee that the height property will be set only once, even though the handler is being invoked multiple times.
Please let me know if you require funder assistance regarding the discussed matter.