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 have a hierarchial grid with parent and child tables. The Grid layout is such that the hierarchical structure looks and acts like a tree.
The root table has a row check column called "chkParent" and the child table has a row checker column called "chkChild". The key data in the grid that I want to work with is the child data. For example I have a DropButton with a list of actions, these actions will be performed against any "Checked" child rows.
The purpose for the parent row checker is so that I can write a JavaScript function to check/uncheck all the children.
The problem I'm having is that the correct will correctly Persist the checked rows for the parent table but not the child table.
Is there any way to have both Parent and Child checked rows persisted correctly.
Regards,
Adrian.
Glen,
I figured out what the issue was. My original version had the markup defining the layout of the gird which never quite worked so I configured my grid in the Code-Behind in the PrepareDataBinding method.
However, I never actually removed the markup which was somehow interfering with the layout generated by the code-behind, so I removed the markup and this has resolved my issue.
In my test, using the property PersistRowChecker="true" and RestoreExpandedChildRows="true" under LayoutSettings in the WebGrid will achieve the result you wanted.
Attached is the simple test sample I used to simulate the scenario in my environment.
I have already been using the settings that you provided and it still doesn't work. There is some slighly strange behaviour, let me explain some more.
I configure my hierarchical grid in the PrepareDataBinding method in the code behind:
WebGridColumnCollection rootColumns = grdEDMPortfolios.RootTable.Columns;rootColumns.Insert(0, new WebGridColumn("chkEDM", AWBConstants.COL_REGISTRATION_ID, " ", new Unit("23px"), ColumnType.CheckBox, EditType.Checkbox, ""));rootColumns.GetNamedItem("chkEDM").IsRowChecker = true;WebGridTable childTable = grdEDMPortfolios.RootTable.ChildTables[0];WebGridColumnCollection childColumns = grdEDMPortfolios.RootTable.ChildTables[0].Columns;childColumns.Insert(0, new WebGridColumn("chkPortfolio", AWBConstants.COL_PORTFOLIO_ID, " ", new Unit("23px"), ColumnType.CheckBox, EditType.Checkbox, ""));childColumns.GetNamedItem("chkPortfolio").IsRowChecker = true;
Here I hide various columns I don't need as well as added my parent row checker column "chkEDM" and my child row checker column "chkPortfolio". The grid layout settings you stated above are set in the markup.
I have also added a client side OnCheckBoxClick function to trigger a parent checkbox to check all children and vice versa. Here is is the code:
function grdEDMPortfolios_CheckBoxClick(gridId, tblName, colName, checkboxValue) { var grid = ISGetObject(gridId); var selectedRow = grid.GetSelectedObject().GetRowObject(); if (colName == "chkEDM") { if (selectedRow.Table.ChildTables.length > 0) { var childRows = selectedRow.GetChildRows("PortfolioCollection"); for (var i = 0; i < childRows.length; i++) { if(!childRows[i].GetCells().GetNamedItem("chkPortfolio").ForceNoEdit) { if (checkboxValue) { childRows[i].Check(); } else { childRows[i].Uncheck(); } } } } } EnableCopyToShell(); return true; }
The behaviour I witness is as follows:
In my test, since you are using bounded data for the checkbox column you will not need to set the IsRowChecker property.
Regarding your issue, since the checkbox is bounded to the database field, you will need to make sure that the corresponding field in the database has already reflect the checkbox value in the WebGrid. The refresh button in the WebGrid will rebound the data from the database to the WebGrid again, so the rendered value reflect the databse value.
The RowChecker columns are not bound to a database field, I manual created the Row Checker columns in the PrepareDataBinding method in the code behind and I still get this strange behaviour.
Any ideas?
Here is the code for creating the row check columns:
WebGridColumnCollection rootColumns = grdEDMPortfolios.RootTable.Columns;rootColumns.Insert(0, new WebGridColumn("chkEDM", "", " ", new Unit("23px"), ColumnType.CheckBox, EditType.NoEdit, ""));rootColumns.GetNamedItem("chkEDM").IsRowChecker = true;rootColumns.GetNamedItem("chkEDM").Bound = false;WebGridTable childTable = grdEDMPortfolios.RootTable.ChildTables[0];WebGridColumnCollection childColumns = grdEDMPortfolios.RootTable.ChildTables[0].Columns;childColumns.Insert(0, new WebGridColumn("chkPortfolio", "", " ", new Unit("23px"), ColumnType.CheckBox, EditType.NoEdit, ""));childColumns.GetNamedItem("chkPortfolio").IsRowChecker = true;childColumns.GetNamedItem("chkPortfolio").Bound = false;
I have modified the test sample to simulate the new detail in your scenario. I still could not replicate the strange behavior you mention in my environment. Could you modify the attached sample to replicate the strange behavior?
The test is done using the latest WebGrid 7 and WebUI Framework 3 build, which is build 402 and build 752.
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