How to implement WebGrid:BatchUpdating ServiceEvent

10 replies. Last post: October 26, 2010 11:16 PM by Maged Mikaeel
Tags :

Hi,

  I've WebGrid, set BindingOperationMode="ClientBinding" and set AllowBatchUpdate="True"


   I need to know how to handle BatchUpdating ServiceEvent. I can't find any sample for that.


Thanks,

Maged

Answers

Great,

Thank you.

All Replies

Any update from any one from Intersoft support team?

We've a dead line to deliver this project and we need you help pls.


Maged

A sample of client binding and batch update has been provided on the ClientBinding_BatchUpdate.aspx sample page.

You will need to set the BatchUpdateMethod property in the ServiceMethods of ClientBindingSettings. Here is an excerpt of the ClientBindingSettings from the sample:

<ClientBindingSettings DataLoadMode="PagedData" DataSourceType="WebService" ItemTypeName="Bug"
ServiceUrl="WebService.asmx">
<ServiceMethods BatchUpdateMethod="UpdateBugs" SelectMethod="GetPagedBugs" />
</ClientBindingSettings>


Actually this is not what I'm looking for!!

I need to know  how to handle "BatchUpdating". There is NO example explains how to handle "BatchUpdatin" client API, like what parameters it takes ...etc


I need an example that shows how to handle and write client function to handle BatchUpdating.


For example we have this:


<ClientBindingSettings DataSourceType="WebService" ServiceUrl="../MembershipDataService.asmx"
        DataLoadMode="AllData" ItemTypeName="MembershipNote">
    <ServiceMethods SelectMethod="GetMembershipNotes" InsertMethod="InsertMembershipNote" />
    <ServiceEvents Selecting="Selecting_MembershipNotes"
                   Inserting="Inserting_Note"
                   Inserted="Inserted_GridData" Updating="Updating_GridData"/>
</ClientBindingSettings>




So I need to know how to implement Updating_GridData() function, I need a sample pls.

Maged

This is suppose to be very simple question, and for two days now I'm waiting for an answer! Please Glenn give me the proper answer ASAP!

The method is implemented in the sample that I pointed out on my previous post. Since the WebGrid is using WebService.asmx, the UpdateBugs method is defined in the WebService.cs under App_Data folder.

Here is the UpdateBugs method I copied from the WebService.cs:

[WebMethod]
[GenerateScriptType(typeof(Bug))]
public TransactionResult UpdateBugs(List<ClientRowChanges> changes)
{
BugTrackerModelDataContext context = new BugTrackerModelDataContext();
WebGridDataProvider<Bug> provider = new WebGridDataProvider<Bug>(context.Bugs.AsQueryable());

return provider.BatchUpdate(changes);
}



This is not what I'm asking for!!!

    I need this one: BatchUpdating ServiceEvent

   So in ClientBindingSettings, you can define BatchUpdating service events like:

<ClientBindingSettings ......
    <ServiceEvents Selecting="Selecting_MembershipNotes"
BatchUpdating="Batchupdating_MembershipNotes"/>
</ClientBindingSettings>

 

I need to know how to write Batchupdating_MembershipNotes.

Please read my request carefully and please reply to me ASAP.... It’s taking too long now.

Maged

 

 

 

I am very sorry for the misunderstanding.

It seems the method definition is not available in the WebGrid docs, I inform our documentation team regarding this issue.

Based on my test with the event handler, the BatchUpdating event handler have 2 parameter the Grid object and the row changes collection object. Here is the snippet:

function Grid_BatchUpdating(gridObject, rowChanges) {

}


Thanks Glenn for your support.

I still need more information here.

I need to know how to:

   1- Iterate through row changes collection object.

   2- The structure of the changes collection object on each item in the collection.

   2- How to make changes (if it’s possible) to some of the items/fields in the collection.

 

Thanks,

Maged

You can iterate the collection using for loop. Here is a simple snippet to update a Component column for a specific row:

function Grid_BatchUpdating(gridObject, rowChanges) {
debugger;

for (var i in rowChanges) {
currRow = rowChanges[i];
if (currRow.NewObject.BugId == "2875")
currRow.NewObject.Component += "-rev";
}
}

You could analyse the structure in more detail using the debugger. As shown in the snippet above, you could modify the data using the NewObject property and column information.  

Great,

Thank you.

All times are GMT -5. The time now is 9:27 AM.
Previous Next