Hello,
My requirement is lazy binding of the column layout. On click of any cell of a row or on click of the expansion indicator of row, I want to load the data for columnlayout in code behind and keep that row in expanded state. With the events - void dataGrid_CellClicked(object sender, Infragistics.Silverlight.CellClickedEventArgs e) { IsCellClicked = true; ActiveRow = (Row)e.Cell.Row; lstCurrentData = (List<ChildNode>)dataGrid.ItemsSource;
string strSelectedID = ((ChildNode)e.Cell.Row.Data).ID; List<ChildNode> lstChildren = new List<ChildNode>(); lstChildren = GetTheDataByParentID(strSelectedID); /* To get the children assign to respective node */ SearchRecursive(lstCurrentData, strSelectedID, lstChildren);
dataGrid.ItemsSource = null; dataGrid.ItemsSource = lstCurrentData; dataGrid.UpdateLayout(); }and void dataGrid_RowExpansionChanged(object sender, Infragistics.Silverlight.RowExpansionChangedEventArgs e) { List<ChildNode> vm = dataGrid.DataContext as List<ChildNode>; lstCurrentData = (List<ChildNode>)dataGrid.ItemsSource; string strSelectedID = ((ChildNode)e.Row.Data).ID; List<ChildNode> lstChildren = new List<ChildNode>(); lstChildren = GetTheDataByParentID(strSelectedID); SearchRecursive(lstCurrentData, strSelectedID, lstChildren); dataGrid.ItemsSource = null; dataGrid.ItemsSource = lstCurrentData; dataGrid.UpdateLayout(); }I get the data in ColumnLayout, but I need the respective row in expanded state. Now as the code in RowExpanded event is reassigning the ItemSource, its not allowing the row to expand on expander arrow click. But as I want to load the data for column layout at the time of expand, I've to do it in that event itself. Is there any other way for this? Please, help.Thanks,Pragati.
Hello Pragati,
Thank you for your post. I have been looking into it and it seems like that this is the best way of achieving the thing you want. If I think of a batter way, I will let you know.
Hello Stefan,I'm using the dll Infragistics.Silverlight.XamWebGrid.v9.2, VS 10, SL4. My data is of multiple depth heirarchy.As I need lazy binding, I tried it orher way. I get the another XamWebGrid in ColumnLayout through TemplateColumn - DataTemplate. To get the cell click event of this grid added in xaml's resources - <UserControl.Resources> <DataTemplate x:Name="MyDataTemplate"> <Grid> <igGrid:XamWebGrid CellClicked="dataGrid_CellClicked" ItemsSource="{Binding Children}"/> </Grid> </DataTemplate></UserControl.Resources>
In code behind -
void dataGrid_RowExpansionChanging(object sender, Infragistics.Silverlight.CancellableRowExpansionChangedEventArgs e) { if (IsRowAlreadyExpanded == false && e.Row.IsExpanded == false) { ActiveRow = (Row)e.Row; dataGrid_CellClicked(sender, new Infragistics.Silverlight.CellClickedEventArgs()); } } void dataGrid_CellClicked(object sender, Infragistics.Silverlight.CellClickedEventArgs e) { if (ActiveRow == null) ActiveRow = (Row)e.Cell.Row; CustomerNode objnode = new CustomerNode(); lstCurrentData = (List<ChildNode>)dataGrid.ItemsSource;
strSelectedID = ((ChildNode)ActiveRow.Data).ID; List<ChildNode> lstChildren = new List<ChildNode>(); /* To get the children of respective node */ lstChildren = objnode.GetTheDataByParentID(strSelectedID, lstParentChildData); /* To search and assign the children to respective nodes for grid ItemSource */ SearchRecursive(lstCurrentData, strSelectedID, lstChildren); if (lstChildren.Count > 0) { TemplateColumn objTempleteColoumn; objTempleteColoumn = new TemplateColumn() { Key = "Children", ItemTemplate = (DataTemplate)this.Resources["MyDataTemplate"] }; try { e.Cell.Column.ColumnLayout.Columns.Add(objTempleteColoumn); ////e.Cell.Row.ColumnLayout.Columns.Add(objTempleteColoumn); } catch (Exception) { throw; } }
IsRowAlreadyExpanded = false; ActiveRow = null; } With this, I get the children data bounded to the grid in template, but I'm not getting the heirarchical display. I get like -
Actually, the grid should be assigned as a child of first row, as I've clicked the cell in first row & data is updated respectively. Please, let me know the better way, how I can assign this Grid of children in columnlayout, if I'm having the same parent in multiple(non-clicked) rows. Additionaly, the basic requirement is I need the specific row & its upper heirarchy in expanded state. Thanks,Pragati.
I have modified the sample I sent you before, so now the ItemsSource of the XamGrid in the Childbands is set when the Row is expanded.
Hope this helps you.
Hello Stefan,Thanks for your reply. But, how can I add the columnlayout(row detail) in code behind?like - TemplateColumnLayout obj = new TemplateColumnLayout();.....ColumnLayouts.Add(TemplateColumnLayout);
Pragati
I have modified the sample further, so now the TempalteColumnLAyout is added in code behind, in the RowInitialized event.
Hello Stefan,Thanks for your reply. The sample project helps me a lot. Now, it seems I'm just a step back to my goal. I need the grid in DataTemplate is to be also AutoGenerateColumns = false. I get this done with assiging the events of root grid to this grid as well. But, while row creation though I'm adding the ColumnLayout only for the nodes having children, the expander indicator & blank row details(ColumnLayout) showing for the nodes which are not having children at all.Code flow is like - 1) Root data (Observable collection) get assigned to root grid. If any node is having chidren, expand indicator is shown, but all rows are collapsed.2) On click of expander or on click of any cell of row, the respective row data updated with children & row gets expanded.Here, if one of the children rows is having chidren in turn & other rows are not having any chidren at all; still all the rows are shown with expand indicator. They get expanded on click with blank template.Attaching the sample project. For csv file, please set the Build Option as Resources in its Properties. I'm using VS10, SL4 and Infragistics dll 10.3Thanks,Pragati.
I have modified the sample I sent me, so now it has the functionality you want. There aren’t ExpansionIndicators if there is no ChildData.
I can suggest you use the XamGrid’s Indentation Property instead of setting the Padding of the ColumnLayout. I have already logged a Product Idea on your behalf about the Virtualization of the XamGrid, which will prevent the scrolling issues. Also the Column Headers are synchronized till the moment you scroll any of the nested grids.
Hello Yanko,I've attached the sample application herewith. With reference to previous posts and sample, you will get idea that; I'm adding the row details dynamically with another Infragistics grid in datatemplate. I'm getting the headers and horizontal scrollbar for each child grid. 1) As the headers of outermost parent & the children of all the levels are same, can I use the outermost headres for all the grids in different level with the outermost scrollbar scrolling all the grids? Stefan had given the solution with opacity of scrollbar = 0, it hides the scrollbars. But, I need to scroll same column in all levels grids synchronously. As I'm having upto 20th - 25th level heirarchy, this may exceed upto 100 even, in such case its not good to see scrollbar for each grid.2) While scrolling vertically, the expanded rows get disturbed. Some get collapsed, some get hidden or unnecessary white space in child grid.3) After expand and collapse all the levels, and again expanding one by one, it shows the blank space of previous expanded levels. I cannot generate it in this sample, but Stefan said that it seems to be expected since the XamGrid has a built-in UI virtualization.4) The headers of child grid are not aligned properly. You can check this expanding the last row element in sample. 5) I need indentaion in Name column as per heirarchy. I already have some indentation for parent grid's column value for some specific rows. So, whatever are those, in child grid I need to add one more space for value in Name column. I've got the indentation for parent with setting the padding in parent grid's ColumnLayoutAssigned event, Depending upon parent row's padding to set the padding for child, I tried in RowExpansionChanging event of parent grid to get its padding with Thickness obj = e.Row.Cells["Name"].Control.Padding; But, its giving 0,0,0,0 though it is 10,0,0,0 in fact. Is the indentaion possible with Padding or any other way is there?
Thanks,Pragati.
Hello pragati,
Would you please attach the final version of your sample application in order to provide you with more accurate assistance ?
Looking forward to hearing from you.
Hello Stefan,In parent grid's ColumnLayoutAssigned event, I've set the padding for secific cells in column 2. I need to add the padding for child grid's cells in column 2 itself, depending upon parent row's padding. I tried in RowExpansionChanging event of parent grid to get the padding with Thickness obj = e.Row.Cells["Description"].Control.Padding; But, its giving 0,0,0,0 though it is 10,0,0,0 in fact.Actually, I need indentation with padding.Please, help.Thanks,Pragati.
Hello Stefan,Back to the scrollbar. In sample project, you have hidden(opacity=0) the scrollbars. But, with this, what I required is - while scrolling either parent grid or child grid, with parent scrollbar or with mouse wheel; all the grids should get scrolled synchronously. One more thing, can we get checked in event RowExpansionChanging, whether the row is getting collapsed or expanded?Please, help.Thank,Pragati.