private void XamWebGrid_CellExitingEditMode(object sender, ExitEditingCellEventArgs e) { Infragistics.Silverlight.Controls.RowBase r = e.Cell.Row; // Ensure using correct cell and editing has not been cancelled if (e.Cell.Column.Key == "StepDescription" && !e.EditingCanceled) { ComboBox box = e.Editor as ComboBox; if (box.SelectedItem != null && ((ListItem)box.SelectedItem).Value!="0") { Web.Cortex.WcfServiceReference.TestStepsProfile obj = new Web.Cortex.WcfServiceReference.TestStepsProfile(); ; int StepId = Int32.Parse(((ListItem)box.SelectedItem).Value); if (TestStepscollection != null && TestStepscollection.Count > 0) { var TestStepsMatch = TestStepscollection.Where(p => p.StepID == 6620); //IEnumerable<Web.Cortex.WcfServiceReference.TestStepsProfile> qry = from c in TestStepscollection // where c.StepID == 6620 // select c; //ObservableCollection<Web.Cortex.WcfServiceReference.TestStepsProfile> filteredClients = new ObservableCollection<Web.Cortex.WcfServiceReference.TestStepsProfile>(qry); //IEnumerable<Web.Cortex.WcfServiceReference.TestStepsProfile> matches = TestS//tepscollection.Where(p => p.StepID == 6620); foreach (Web.Cortex.WcfServiceReference.TestStepsProfile TestStep in TestStepsMatch) { rr.Cells["StepObjectClass"].Content = TestStep.StepObjectClass; r.Cells["StepObjectClass"].Content = TestStep.StepObjectClass == null ? "" : TestStep.StepObjectClass; r.Cells["StepObjectName"].Content = TestStep.StepObjectName == null ? "" : TestStep.StepObjectName; //r.Cells["StepObjectAction"].Content = TestStep.StepObjectAction == null ? "" : TestStep.StepObjectAction; r.Cells["StepID"].Content = TestStep.StepID == null ? "" : TestStep.StepID.ToString(); r.Cells["StepOrder"].Content = e.Cell.Row.Index + 1; gridTransaction.Rows.Add((Row)r); //TestStep.StepOrder = e.Cell.Row.Index + 1; //TestStepList.Add(TestStep); } } // New value is value of selected item in combo box ////e.NewValue = ((ListItem)box.SelectedItem).Text; box.ItemsSource = null; box.SelectedItem = null; } } }
In above code I want to add the row in the grid.But as am doing
Infragistics.Silverlight.Controls.RowBase r = e.Cell.Row; So the same row get copied again...
So anyone help me how to add new row in grid.I don't want to do it by modifying the collection object.
I am not sure what you wouldn't want to add the row to the underlying collection, as this is what the grid is going to do with the data object you provide to populate the row.
But to add a new row you would call the CreateItem() method off the Rows collection where the row will belong. You would probably want to use the CreateItem overload that allows you to pass in the dataobject that will be associated with the Row.
after that you can just add the row to the rows collection
Infragistics.Controls.Grids.Row r =grid.Rows.CreateItem();
grid.Rows.Add(r);
Hello Darell,
I have the grid having column Sort Order
First time there is a blank row in the grid having sort order 0 and a combobox in one of the column.
When I select the item from combobox I need to add row on the basis of that item in the grid with sortorder = rowindex+1,But I want the blank row with sortorder 0 always at the end.
ex -like in below order I want to display the rows in grid.
SortOrder
1
2
3
0
Thats why I think it is better to add rows in grid not by modifying collection.
But still struggling to find the solution.
-Pankaj