|
|
|
Rank: Newbie
Groups: Registered
Joined: 7/28/2010 Posts: 7
|
I am trying to use the inline cell editing. The problem is when I edit a cell and press enter, it saves the cell that I edited but all the other cells of that row is set to null or blank. Is this a bug or something? Code below is for a subgrid that populates using employeeid from parent grid. Database is from the sample mdb on the download page. Quote:
<asp:AccessDataSource ID="AccessDataSource2" runat="server" DataFile="~/App_Data/Northwind.mdb" SelectCommand="SELECT [OrderID], [OrderDate], [ShippedDate], [Freight] FROM [Orders] WHERE [EmployeeID] = ?" UpdateCommand="UPDATE [Orders] SET [OrderDate] = ?, [ShippedDate] = ?, [Freight] = ? WHERE [OrderID] = ?"> <SelectParameters> <asp:Parameter Name="EmployeeID" Type="Int32" /> </SelectParameters> <UpdateParameters> <asp:Parameter Name="OrderDate" Type="DateTime" /> <asp:Parameter Name="ShippedDate" Type="DateTime" /> <asp:Parameter Name="Freight" Type="Decimal" /> <asp:Parameter Name="OrderID" Type="Int32" /> </UpdateParameters> </asp:AccessDataSource> --Child grid <trirand:JQGrid runat="server" ID="JQGrid2" EditInlineCellSettings-Enabled=true DataSourceID="AccessDataSource2" OnDataRequesting="JQGrid2_DataRequesting" > <Columns> <trirand:JQGridColumn DataField="OrderID" PrimaryKey="True"/> <trirand:JQGridColumn DataField="OrderDate" Editable="true" DataFormatString="{0:d}" /> <trirand:JQGridColumn DataField="ShippedDate" Editable="true" DataFormatString="{0:d}" /> <trirand:JQGridColumn DataField="Freight" Editable="true"/> </Columns> <EditInlineCellSettings Enabled="true" /> <HierarchySettings HierarchyMode="Child" /> <ToolBarSettings ShowEditButton="true" ShowRefreshButton="True" ShowAddButton="true" ShowDeleteButton="true" ShowSearchButton="True" /> </trirand:JQGrid>
|
|
|
|
Rank: Advanced Member
Groups: Registered
Joined: 7/12/2010 Posts: 82
|
Hello, Currently the results in Inline Editing are returned as a HashTable and all values that do not exist in the request (e.g. all the rows of the cell values in a row) will indeed be null. It is relatively easy to deal with that however, just take a look at our example here: http://www.trirand.net/e...ell_inline/default.aspx
and how we are checking for null values in editable cells. Code: protected void JQGrid1_RowEditing(object sender, Trirand.Web.UI.WebControls.JQGridRowEditEventArgs e) { DataTable dt = GetData(); dt.PrimaryKey = new DataColumn[] { dt.Columns["EmployeeID"] }; DataRow rowEdited = dt.Rows.Find(e.RowKey);
/// IMPORTANT: /// Since this is cell editing mode, only the cell being edited is sent in RowData /// Therefore we need to check for null values for all cells in the row
if (e.RowData["FirstName"] != null) rowEdited["FirstName"] = e.RowData["FirstName"]; if (e.RowData["LastName"] != null) rowEdited["LastName"] = e.RowData["LastName"]; if (e.RowData["BirthDate"] != null) { DateTime parsedDate = new DateTime(); if (DateTime.TryParse(e.RowData["BirthDate"], out parsedDate)) rowEdited["BirthDate"] = e.RowData["BirthDate"]; else JQGrid1.ShowEditValidationMessage("Date format not valid"); }
JQGrid1.DataSource = GetData(); JQGrid1.DataBind(); } Kind Regards, NoelT Trirand Inc. Support Team
|
|
|
|
Rank: Newbie
Groups: Registered
Joined: 7/28/2010 Posts: 7
|
noeIT, thank you for the quick response. One more issue. I am using the exact copy of the code on the site you gave me. When I hit enter, I can see the change on the grid however on the database, there is no change. When I recompile the page, the changes are reset to original value ... Do I need to add any "Save" procedure?
|
|
|
|
Rank: Advanced Member
Groups: Registered
Joined: 7/12/2010 Posts: 82
|
Hello, This is the code from our samples demo pages and what we update is actually just an in-memory ADO.NET datatable (we do not wish to hit the database in the demos, since we have many people browsing the site and this will garble the database). In your case, you would do an UPDATE Sql Statement to update the row with the primary key and its new values. Kind Regards, NoelT Trirand Inc. Support Team
|
|
|
|
Rank: Newbie
Groups: Registered
Joined: 7/28/2010 Posts: 7
|
Finally got it working. Thanks for the info Noelt :) Case closed.
|
|
|
|
Guest
|
YAFPro Theme Created by Jaben Cargman (Tiny Gecko)Powered by YAF 1.9.3 |
YAF © 2003-2009, Yet Another Forum.NETThis page was generated in 0.162 seconds.