Hi, I have set up my xamGrid but cannot seem to even enter edit mode at this point. I want to start off with an empty xamGrid, and have the user fill in the data, then save it to a database. Here is xaml,
<ig:XamGrid HorizontalAlignment="Left" AutoGenerateColumns="False" Margin="45,334,0,0" Name="xamGrid1" VerticalAlignment="Top" Height="241" Width="302"> <ig:XamGrid.Columns> <ig:UnboundColumn HeaderText="Book Code" Key="sBookCode" Width="100"></ig:UnboundColumn> <ig:UnboundColumn HeaderText="Page Type" Key="sPageType" Width="100"></ig:UnboundColumn> <ig:TextColumn HeaderText="Page Number" Key="sPageNumber" Width="100"></ig:TextColumn> </ig:XamGrid.Columns> <ig:XamGrid.AddNewRowSettings> <ig:AddNewRowSettings AllowAddNewRow="Top" IsEnterKeyEditingEnabled="True" IsF2EditingEnabled="True" IsMouseActionEditingEnabled="SingleClick" IsOnCellActiveEditingEnabled="True"></ig:AddNewRowSettings> </ig:XamGrid.AddNewRowSettings> <ig:XamGrid.EditingSettings> <ig:EditingSettings AllowEditing="Cell" IsEnterKeyEditingEnabled="True" IsF2EditingEnabled="True" IsMouseActionEditingEnabled="SingleClick" IsOnCellActiveEditingEnabled="True" /> </ig:XamGrid.EditingSettings> </ig:XamGrid>
When I single click on the row, nothing happens, cannot type anything. Does the grid have to have a databinding or an itemsource to operate off of? F2 editing does not work, adding this code does nothing as well.
private void xamGrid1_CellClicked(object sender, Infragistics.Controls.Grids.CellClickedEventArgs e) { xamGrid1.EnterEditMode((Row)xamGrid1.ActiveCell.Row, xamGrid1.ActiveCell); }
So I'm curious, what is required for the xamGrid to actually enter edit mode? Also, I found a similar project with the following code and it worked great, just like I want it to work in mine.
private void gridKeywords_RowAdding(object sender, Infragistics.Controls.Grids.CancellableRowAddingEventArgs e) { PODRIAServicesLibrary.Web.Model.JobTag newRow = (PODRIAServicesLibrary.Web.Model.JobTag) e.Row.Data; newRow.JobID =((PrintOnDemand.ViewModel.EditJobViewModel) gridKeywords.DataContext).CurrentJob.JobID; ((ViewModel.EditJobViewModel)gridKeywords.DataContext).CurrentJob.JobTags.Add(newRow); e.Cancel = true; }
The only difference I can see is the ViewModel have bindings set to the grid and creates a binding to the ID before editing, so that when the data is entered, it is already associated with an ID
Hi,
You're going to need to bind to a collection of some class, although the collection could be empty. I'll add my sample so you can see how it would behave.
You have already defined the AddNewRow in the xamGrid and when your users key in the values into the add new row, the row would be entered into the collection. No need for any additional code in the RowAdding event.
I defined my columns as TextColumns instead of the UnboundColumns that you used. unless you have some other purpose for the unbound columns.
Please let me know if you have any questions.
I didnt realize I could use an empty collection. The row adding is working now however I am still having trouble on my end saving the data into the database. I was able to find some nice documentation on the row adding so thanks for that, but couldnt fond much on submitting changes to the database using entity framework. Thanks for your help.
Was that information helpful to you?
This site should be helpful to you. Mihail’s blog describes using the WCF Ria Services and at the end he mentions using SubmitChanges() method to update the database.
https://ko.infragistics.com/community/blogs/b/mihail_mateev/posts/using-the-infragistics-xamgrid-with-ria-services