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.
Hello Stefan,Thanks for your reply. Actually, my requirement is, I need the default height of all the rows in main grid and grid in datatemplate of row detail, to be 20. Is this possible?Thanks,Pragati.
As I said in my previos post when you set the Height the XamGrid cannot resize itself anymore whn it is expanded and the child Rows won't be visible.
Hope this helps you.
Thanks Stefan for your quick reply.Pragati.
Hello Stefan,As shown here, for the row details, I've skipped the headers, but the horizontal scrollbar is coming for every grid through heirarchy. 1) Can I hide these scrollbar as well and can handle the scrolling of all the child grids / expanded grids with that of outermost - main grid's scrollbar? As I'm having upto 20th - 25th level heirarchy, this may exceed upto 100 even, in such case its not good to see these much scrollbars there.2) Another point is, I'm going to indent the description as per the heirarchy, so with such heirarchy later the description of further items may get hidden due to column legth. Due to headers invisible, we cannot go for auto fit option - on double cilicking the headers edge. So, can we use the outermost grid's header click for this?Please, help.Thanks,Pragati.
I have modified the sample I sent you before, so now the horizontal scrollbars won’t appear, but you will be able to scroll horizontally with a mouse’s scroll button. Basically I handled the CellControlAttached event and set the ScrollBar’s Opacity to 0.
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.