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
You could modify the snippet so instead of iterating e.Rows you will iterate the WebGrid datasource or you will need to requery the data if the WebGrid do not cache the data.
Here is the updated snippet that will iterate the WebGrid datasource, in my scenario the DataSource is a DataTable:
protected void wgTest_CustomAggregate(object sender, ISNet.WebUI.WebGrid.CustomAggregateArgs e){ if (e.Column.DataMember == "Date") { DataTable dtSource = (DataTable)wgTest.GetCachedDataSource(); Double sumVal = 0; Double sumValX = 0; for (int i = 0; i < dtSource.Rows.Count; i++) { sumVal += (Double)dtSource.Rows[i]["Value"]; sumValX += (Double)dtSource.Rows[i]["ValueX"]; } e.AggregateResult = sumValX + " / " + sumVal + " : " + ((Double)(sumValX / sumVal)).ToString("#.#0"); }}
The text dump is the ophuscated javascript that used by our component. Based on the generated date of the javascript, 8/7/2009, it indicate that you are still older version of our resources.
If you are using WebGrid 7 build 400 please use WebUI Framewok 3 build 750 and make sure you already update your WebGrid resources. In order to update the WebUI Framework please copy these files to your project bin folder:- ISNet.dll- ISNet.WebUI.dll- ISNet.WebUI.Resources.dll (If you are using SmartWebResources)
If you are not using SmartWebResources you will need to copy the latest WebUI Framework & WebGrid javascript to your CommonLibrary virtual directory folder.
CustomAggegrate function has already support this scenario. For example if you wish to calculate the sum[ValueX] / sum[Value] on the column Date. Here is the snippet:
protected void wgTest_CustomAggregate(object sender, ISNet.WebUI.WebGrid.CustomAggregateArgs e){ if (e.Column.DataMember == "Date") { WebGridRowCollection rows = e.Rows; Double sumVal = 0; Double sumValX = 0; for (int i = 0; i < rows.Count; i++) { WebGridCell cellVal = rows[i].Cells.GetNamedItem("Value"); sumVal += (Double)cellVal.Value; WebGridCell cellValX = rows[i].Cells.GetNamedItem("ValueX"); sumValX += (Double)cellValX.Value; } e.AggregateResult = ((Double)(sumValX / sumVal)).ToString("#.#0"); }}
In this example both the Value and ValueX column has a Double datatype.
You could read the CustomAggegrate walkthrough in or WebGrid documentation under the article "Walkthrough: Using Custom Aggregate function in WebGrid"
I have created a simple sample using the scenario you described. After selecting a row in the WebGrid #1, WebGrid #2 will load a new data source.
I have done some small modification in the technique you used in the attached sample. However, I think you could still achieve the desired result.
In the snippet you provided, you are trying to use a client side function to handle a server side event. As I mentioned before, WebScheduler RefreshAll is a client side function so it should be invoked in the client side event such as the events defined under ClientSideEvents property.
In the previous post you mention:
On the same page, i have button to insert record into Events and RecurringEvents table. When i click the button and insert record and the page is post back, the content in WebScheduler is not updated accordingly, the WebScheduler still show calendar only without any event. I need to refresh the page manually in order for the WebScheduler to "refresh".
If the issue occurs after full postback, you could try to invoke the RefreshScheduler function during HTML body OnLoad client side event handler.
If the suggestion does not solve the issue please send us a sample of the page so we could help you determine the issue.
In order to preserve the column structure and order in RefreshAll using your approach, you will need to add the column as the order in the previous WebGrid not by setting the position property. Here is the modified snippet of the PrepareDataBinding event handler:
protected void WebGrid1_PrepareDataBinding1(object sender, ISNet.WebUI.WebGrid.DataSourceEventArgs e){ if (!IsPostBack || WebGrid1.FlyPostBackAction == PostBackAction.RefreshAll) { System.Collections.Generic.Dictionary<string, Unit> columnSize = new System.Collections.Generic.Dictionary<string, Unit>(); System.Collections.Generic.Dictionary<string, int> columnPosition = new System.Collections.Generic.Dictionary<string, int>(); for (int i = 0; i < WebGrid1.RootTable.Columns.Count; i++) { columnSize.Add(WebGrid1.RootTable.Columns[i].Name, WebGrid1.RootTable.Columns[i].Width); columnPosition.Add(WebGrid1.RootTable.Columns[i].Name, WebGrid1.RootTable.Columns[i].Position); } if (!(columnPosition.Count > 0)) { columnPosition.Add("Application",0); columnPosition.Add("Workflow", 1); columnPosition.Add("ActivityDisplayName", 2); } WebGrid1.RootTable.Columns.Clear(); foreach (string key in columnPosition.Keys) { WebGridColumn Col2 = new WebGridColumn(); Col2.Name = key; Col2.Bound = true; Col2.DataMember = key; WebGrid1.RootTable.Columns.Add(Col2); if (columnSize.Count > 0) Col2.Width = columnSize[Col2.Name]; } } WebGrid1.RootTable.DataMember = "skworkitem";}
Since the original question of this thread has been solved, next time please create a new thread if you have a new question.
WebScheduler have a method to refresh the data programatically using the RefreshAll client side function. Here is the snippet:
function RefreshScheduler() { var sched = ISGetObject("WebScheduler1"); sched.RefreshAll();}
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