Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
140
using xamGrid edit cells to enter data
posted

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

Parents
No Data
Reply
  • 12875
    Verified Answer
    posted

    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.

    SL_xamGrid_BTC_Empty.zip
Children