Hello,
I have an application that uses the XamGrid and i would like to navigate throught it by buttons.
When the XamGrid is in a "normal" state as that :
The navigation i implemented works fine (even with filters).
The problem concern the group, when i want to pass to the next element as that :
I got an exception because the next element taken is the value inside the cell (here a string).
Is there a way to solve it ?
I join a .sln to show you how i implemented the navigation.
Regards.
Is anyone can help me ?
Hi,
I ran you sample and realized that you need to determine if the activecell is part of a GroupByRow and decide what to do if it is.
I added some code to your AllerSuivant event to give you the idea.
Please let me know if you have any questions.
I hadn’t heard back from you and I was wondering if you had further questions.
I'm sorry but i had other issues and i didn't responde.
Your solution helped me a little bit but i didn't had time to think about it as i wanted, so I have a question about the positionning on the first element of the next group : how can i select it ?
I didn't find if i can do it with the GroupByData or with the Rows and IsSelected properties.
Regards
I worked thru your sample again and made modifications to the AllerSuivant function so that it will skip to the next row in a groupby collection or to the next expended groups' first row.
protected void AllerSuivant(object o){ // grille is the xamGrid control var grille = ((XamGrid)o);
// Determine if the active cell is part of a GroupByRecord and not a DataRecord if (grille.ActiveCell is Infragistics.Controls.Grids.Primitives.GroupByCell) { return; }
// Once you know that the active row is a Row, you acquire the parent GroupByRow // the idea is to determine how many rows are in the GroupByRow collection and then // ...... move accordingly.
//gbr is the parent GroupByRow of the current Active cell's Row Infragistics.Controls.Grids.Primitives.GroupByRow gbr = (Infragistics.Controls.Grids.Primitives.GroupByRow)(grille.ActiveCell.Row as Infragistics.Controls.Grids.Row).ParentRow; // Assuming you just want to set the selected row to the next row, // skipping to the first in the next groupbyrows when necessary // current postion grille.ActiveCell.Row.Index // maximum num of rows - grille.Rows.Count
int gridRowIdx = 0;
if (grille.ActiveCell.Row.Index < gbr.Rows.Count - 1) { //increment index to next row in group gridRowIdx = grille.ActiveCell.Row.Index + 1;
this.PersSelected = (Person)gbr.Rows[gridRowIdx].Data; gbr.Rows[gridRowIdx].IsSelected = true; gbr.Rows[gridRowIdx].Cells[0].IsSelected = true; gbr.Rows[gridRowIdx].Cells[0].IsActive = true; grille.Rows[gridRowIdx].IsActive = true; } else { //need to acquire the next groupbyrow and if it is expanded, set it's first row as active and selected // you will also need to consider levels if more than 1 level of grouping int gbrRowIdx = gbr.Index; for (int idx = gbrRowIdx + 1; idx < grille.Rows.Count; idx++) { if (grille.Rows[idx] is Infragistics.Controls.Grids.Primitives.GroupByRow) { if (grille.Rows[idx].IsExpanded) { Infragistics.Controls.Grids.Primitives.GroupByRow gbrC = (Infragistics.Controls.Grids.Primitives.GroupByRow) grille.Rows[idx]; gridRowIdx = gbrC.Rows[0].Index;
this.PersSelected = (Person)gbrC.Rows[0].Data; gbrC.Rows[0].IsSelected = true; gbrC.Rows[0].Cells[0].IsSelected = true; gbrC.Rows[0].Cells[0].IsActive = true; gbrC.Rows[0].IsActive = true;
// Break out of for loop idx = grille.Rows.Count; } } }
} }
I left in your code for assigning the PersSelected to the data but you should check that is doing what you expected.
Let me know if you have any questions.
thanks a lot for you anwser, the code helped me to understand the principe but i have another question about the level of grouping.
I found a property "Level" in the property GroupByRow but its value is always 0, is there a particular way to use it ?
Hi Fabian,
Thanks for posting your solution. I’m sure it will be interesting to others.
Please let me know if you have further questions.
I tried you suggestion bu it didn't work, i already had a binding on the ActiveItem and affect it or the element produce the same issue.
But i found a solution by using the following properties :
- ScrollCellIntoView : it shows the good element,
- IsSelected : on the row to highlight it,
- IsActive : on the first cell of the row to get the data of the row.
I attach the solution if anyone else is interest.
Regards ans thanks for the help.
Fabien.
HI,
I didn't see your response. Please take the time you need to review.
I was wondering if you had further questions.
Sorry I didn't try what you suggested yet. I'll write you in few days.