User Profile & Activity

Glenn Layaar Support
Page
of 99
Posted: February 8, 2010 4:50 AM

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");
}
}


As mentioned before, the reported issue by Attila Tello will be fix with the new hotfix build which will be available very soon.

In the mean time, please provide us with a more detail error message, screenshot of the error will suffice, and if possible please provide us with a running sample so we could try to replicate the issue more easily in our enviroment. 

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.

Posted: February 7, 2010 9:53 PM

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"

Posted: February 4, 2010 10:56 PM

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.

Posted: February 4, 2010 3:56 AM

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.

Posted: February 3, 2010 10:12 PM

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";
}


Posted: February 3, 2010 8:25 PM
As I mentioned before, the RefreshAll is a client side function (Javascript function) so it should be invoke in the client side.

I have already provided a snippet of the RefreshAll function in my previous post. You will need the WebScheduler object reference and call the RefreshAll function.
Posted: February 3, 2010 2:34 AM

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();
}


Posted: February 3, 2010 1:15 AM
The NewRow row tipe behavior for linked WebCombo fix will be included in the next hotfix which will be released very soon
All times are GMT -5. The time now is 11:24 PM.
Previous Next