New to Telerik, so forgive my ignorances but I am stuck on how to update data in my grid.
I have a grid that uses the NeedDataSource method to bind to a list of objects
With my method like:
This is properly populating my grid.
I have set up the grid so that a doubleclick event on a line runs a client side script:
This in turn opens my grid with an edit control, as defined in my mark up:
What I can not figure out is now what? I tried to add an event to the grid
And in here I am not sure what all I need to do. In order to do what I need I must call a .Save() event on my Object that is contained in the grid, in order to persist back to a database. I would think that in my code I could just do something like:
This of course doesn't do anything. My edited values do not get passed back into the entity. Do I need to actually do something to pass the edit control values into my object? How can I account for the various data types that the object's properties contain?
As you can probably tell I am pretty confused. All of the samples that I have found discuss updates only against grids with defined datasourceids using what appears to be automatic updates. I would hope that with a grid bound the way I have it that the grid edits would update the object it is bound to and I would just need to do the final object .Save event. Doesn't seem to be the case.
I have a grid that uses the NeedDataSource method to bind to a list of objects
<MasterTableView DataKeyNames="Id" Width="100%" AutoGenerateColumns="False" |
OnNeedDataSource="RadGrid1_NeedDataSource"> |
With my method like:
protected void RadGrid1_NeedDataSource(object source, GridNeedDataSourceEventArgs e){ |
IList<FXGroup> FXData = new List<FXGroup>(); |
RadGrid1.DataSource = FXData; |
This is properly populating my grid.
I have set up the grid so that a doubleclick event on a line runs a client side script:
function GridRowDblClick(sender, eventArgs) { |
editedRow = eventArgs.get_itemIndexHierarchical(); |
$find("<%= RadGrid1.MasterTableView.ClientID %>").editItem(editedRow); |
} |
This in turn opens my grid with an edit control, as defined in my mark up:
<telerik:GridBoundColumn DataField="Quantity" HeaderText="Qty" |
SortExpression="Quantity" UniqueName="Quantity" ReadOnly="False" ColumnEditorID="GridQuantityEditor" EditFormColumnIndex="0" > |
</telerik:GridBoundColumn> |
... |
<telerik:GridNumericColumnEditor ID="GridQuantityEditor" runat="server" NumericTextBox-Width="50px" NumericTextBox-NumberFormat-DecimalDigits="0" /> |
What I can not figure out is now what? I tried to add an event to the grid
OnUpdateCommand="RadGrid1_UpdateCommand" |
And in here I am not sure what all I need to do. In order to do what I need I must call a .Save() event on my Object that is contained in the grid, in order to persist back to a database. I would think that in my code I could just do something like:
protected void RadGrid1_UpdateCommand(object source, Telerik.Web.UI.GridCommandEventArgs e) |
{ |
GridEditableItem editedItem = e.Item as GridEditableItem; |
GridEditManager editMan = editedItem.EditManager; |
object item = GetObjectByID(editedItem.OwnerTableView.DataKeyValues[editedItem.ItemIndex]["Id"].ToString()); |
item.Save(); |
} |
This of course doesn't do anything. My edited values do not get passed back into the entity. Do I need to actually do something to pass the edit control values into my object? How can I account for the various data types that the object's properties contain?
As you can probably tell I am pretty confused. All of the samples that I have found discuss updates only against grids with defined datasourceids using what appears to be automatic updates. I would hope that with a grid bound the way I have it that the grid edits would update the object it is bound to and I would just need to do the final object .Save event. Doesn't seem to be the case.