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
I have an aspx page with button and grid. When button is clicked, modal dialog is shown for adding new item. After closing modal dialog, grid sends custom postback like this:
function NewItem() { var result = showModalDialogIframe("Edit.aspx", "", "dialogWidth=1000px;dialogHeight=800px"); if (result == '1') { var grid = ISGetObject("WebGrid1"); grid.SendCustomRequest(); } }
On the server side in the WebGrid1_InitializePostBack event handler datasource is refreshed like this:
protected void WebGrid1_InitializePostBack(object sender, PostbackEventArgs e) { if (e.Action == ISNet.WebUI.WebGrid.PostBackAction.Custom) { // refresh webgrid data DoInitializeDataSource(); WebGrid1.DataSource = ds; WebGrid1.ClientAction.Refresh(); } }
Grid has 3 levels of grouping. I want to show new item and coresponding groups expanded.
I did something like this:
protected void WebGrid1_InitializeRow(object sender, RowEventArgs e) { if (e.Row.Type == ISNet.WebUI.WebGrid.RowType.Record) { if (e.Row.Table.IsRootTable) { int newID = Convert.ToInt(Session["NewID"]); if (e.Row.KeyValue.ToString() == newID.ToString()) { var rootRow = e.Row.GetRootRow(); bool found = false; foreach (WebGridRow rr in rootRow.Children) { foreach (WebGridRow rr2 in rr.Children) { if (rr2.Cells[0].Text == e.Row.Parent.Cells[0].Text) { rootRow.ExpandGroupRow(); rr.ExpandGroupRow(); rr2.ExpandGroupRow(); found = true; break; } } if (found) { break; } } //e.Row.Expanded = true; Session["NewID"] = null; } } } }
However, it doesn't work, at least not completely. The way it works is shown in the attached screenshot.
Is there an easier or better way to expand all the groups all the way down to the one row?
For my case, that can't work. On my button click function row is inserted in the database. That is why I use grid.SendCustomRequest(); and WebGrid1_InitializePostBack event handler so that datasource is refreshed with new row.
Also, your approach to expanding is top to bottom. Your code gets first group and expands it, and then expands all the children. I want to expand only groups and subgroups that lead to the new row (the one that was inserted on button click).
However, I found another way.
On the server-side in InitializeRow event handler, I first detect positions of the coresponding groups and invoke function on the client-side with those group positions.
protected void WebGrid1_InitializeRow(object sender, RowEventArgs e) { if (e.Row.Type == ISNet.WebUI.WebGrid.RowType.Record) { if (e.Row.Table.IsRootTable) { int? newSastanakID = ConvertSafeNullable.ToInt(Session["NoviSastanak"]); if (newSastanakID.HasValue && e.Row.KeyValue.ToString() == newSastanakID.Value.ToString()) { var rootRow = e.Row.GetRootRow(); bool found = false; int rootLevel = 0; int subLevel = 0; int subsublevel = 0; foreach (WebGridRow rr in rootRow.Children) { foreach (WebGridRow rr2 in rr.Children) { if (rr2.Cells[0].Text == e.Row.Parent.Cells[0].Text) { rootLevel = rootRow.Position; subLevel = rr.Position; subsublevel = rr2.Position; found = true; break; } } if (found) { break; } } WebGrid1.ClientAction.InvokeScript("ExpandToRow", new ISNet.WebUI.FunctionParameter[] { new ISNet.WebUI.FunctionParameter(rootLevel.ToString(), "int"), new ISNet.WebUI.FunctionParameter(subLevel.ToString(), "int"), new ISNet.WebUI.FunctionParameter(subsublevel.ToString(), "int") }); Session["NoviSastanak"] = null; } } } }
The client-side function looks like this:
function ExpandToRow(rootLevel, subLevel, subsubLevel) { var grid = ISGetObject("WebGrid1"); var rootRow = grid.RootTable.GetRowByGroup(0, rootLevel); rootRow.ExpandGroupRow(); var subRow = rootRow.GetGroupChildRows()[subLevel]; subRow.ExpandGroupRow(); subRow.GetGroupChildRows()[subsubLevel].ExpandGroupRow(); return; }
This way, only the groups that row is member of, are expanded.
Hello,
Unfortunately, there is no method to expand all if you have more than 1 group levels.I think it is more easier if you handle this in client side.Please see my attached code. I am using on button click.
function Button1_onclick() { var grid = ISGetObject("WebGrid1"); var currentRow = grid.GetSelectedObject().GetRowObject(); currentRow.ExpandGroupRow(); // expand group row for (var i = 0; i < currentRow.GetGroupChildRows().length; i++) { currentRow.GetGroupChildRows()[i].ExpandGroupRow(); } return true; }
Regards,Handy
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