iSeller Commerce
iSeller POS Retail
iSeller POS F&B
iSeller POS Express
Crosslight
WebUI
ClientUI
What's New
Download Trial
Web Solution
Mobile Solution
Enterprise Solution
Custom Development
Blog
Community
Latest Development Blogs
ForumPostTopic
Browse By Tag
Hi,
I'm trying to modify some records on a childrow from the parentrow in a hierarchical grid with batch update (as reference, I'm using part of the answer for some another reply I got in this thread ).
Problem is, when I'm picking the BatchUpdate event not all the changes are showing up on the BatchUpdateEventArgs.PendingChanges collection, only the changes on the parent rows are there. I'm clicking the rowchecker on the parent row and that's supposed to trigger some changes on both the parent and its children. I think this might be an issue with the code I'm using to "commit the change" on the rows.
This is in my javascript event:
function webGrid_CheckBoxClick(gridId, tblName, colName, checkboxValue, originalCheckBoxValue) { var grid = ISGetObject(gridId); var row = grid.Tables[tblName].ToRowObject(grid.CheckedRowContext); if (colName == 'Checker') { var newCountryName = row.GetCell('CountryName').Text + "_New"; row.GetCell('CountryName').SetValue(newCountryName); row.GetCell('CountryName').SetText(newCountryName); row.GetCell('Active').CellElement.childNodes[0].click(); //Expand child if (!row.ChildExpanded) { row.ExpandChildRow(true); } //If no childs return var childRows = row.GetChildRows("Capital"); if (childRows == null) { return; } //Check all childs and retrigger function for (var i = 0; i < childRows.length; i++) { childRows[i].Check(); } row.SetDataChanged(); row.AcceptChanges(); grid.MarkEdit(); } else if (colName == 'CapitalChecker') { var newCapitalName = row.GetCell('CapitalName').Text + "_New"; row.GetCell('CapitalName').SetValue(newCapitalName); row.GetCell('CapitalName').SetText(newCapitalName); row.GetCell('CapitalActive').CellElement.childNodes[0].click(); row.SetDataChanged(); row.AcceptChanges(); grid.MarkEdit(); } }
And this is my grid definition:
<ISNet:WebGrid ID="webGrid" runat="server" UseDefaultStyle="true" OnInitializeDataSource="webGrid_IDS" OnBatchUpdate="webGrid_BU"> <RootTable DataMember="Country" DataKeyField="CountryID"> <Columns> <ISNet:WebGridColumn ColumnType="CheckBox" IsRowChecker="true" Name="Checker" Bound="false" /> <ISNet:WebGridColumn DataMember="CountryID" Name="CountryID" /> <ISNet:WebGridColumn DataMember="CountryName" Name="CountryName" /> <ISNet:WebGridColumn DataMember="Active" Name="Active" /> </Columns> <ChildTables> <ISNet:WebGridTable DataMember="Capital" DataKeyField="CapitalID" > <Columns> <ISNet:WebGridColumn ColumnType="CheckBox" IsRowChecker="true" Name="CapitalChecker" Bound="false" /> <ISNet:WebGridColumn DataMember="CapitalID" Name="CapitalID" /> <ISNet:WebGridColumn DataMember="CapitalName" Name="CapitalName" /> <ISNet:WebGridColumn DataMember="Active" Name="CapitalActive" /> </Columns> </ISNet:WebGridTable> </ChildTables> </RootTable> <LayoutSettings AllowBatchUpdate="true" AllowEdit="Yes" Hierarchical="true"> <ClientSideEvents OnCheckBoxClick="webGrid_CheckBoxClick"/> <BatchUpdateSettings PromptUnsavedChanges="false" /> </LayoutSettings> </ISNet:WebGrid>
And this is in my code behind:
protected void webGrid_IDS(object sender, DataSourceEventArgs e) { e.DataSource = GetDataSet(); } protected void webGrid_BU(object sender, BatchUpdateEventArgs e) { var changeCount = e.PendingChanges.Count; var changeCollection = e.PendingChanges; foreach (var change in changeCollection) { } } protected void btnBatchUpdate_Click(object sender, EventArgs e) { webGrid.PerformBatchUpdate(false); } private DataSet GetDataSet() { DataSet test = new DataSet(); DataTable country = test.Tables.Add("Country"); DataTable capital = test.Tables.Add("Capital"); country.Columns.Add("CountryID", typeof(int)); country.Columns.Add("CountryName", typeof(string)); country.Columns.Add("Active", typeof(bool)); capital.Columns.Add("CapitalID", typeof(int)); capital.Columns.Add("CountryID", typeof(int)); capital.Columns.Add("CapitalName", typeof(string)); capital.Columns.Add("Active", typeof(bool)); country.Rows.Add(1, "France", false); country.Rows.Add(2, "Spain", false); capital.Rows.Add(10, 1, "Paris", false); capital.Rows.Add(20, 2, "Madrid", false); test.Relations.Add(new DataRelation("CountryCapital", country.Columns[0], capital.Columns[1])); return test; }
Thanks for any feedback on this
Hello Guilermo,
After I look into your codes, there's happened to be a mistake.
Please delete this 3 lines
row.SetDataChanged(); row.AcceptChanges(); grid.MarkEdit();
and change it into
row.AddPendingChanges(); grid.UpdatePendingChangesStatus();
When you have a case which deal with a database please update it using these 2 commands.
Thank you.
Hope this can resolve your issue.
Best regards,
Niven Prasetya
Thanks Niven, it works now.
or
Choose this if you're already a member of Intersoft Community Forum. You can link your OpenID account to your existing Intersoft Social ID.
Choose this if you don't have an Intersoft account yet. Your authenticated OpenID will be automatically linked to your new Intersoft account.
Enter your Wordpress Blogname