This is a migrated thread and some comments may be shown as answers.
Additional parameter to WCF Service Update method
4 Answers 20 Views
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Bogdan Cucosel
Top achievements
Rank 1
Bogdan Cucosel asked on 10 Oct 2012, 07:23 PM
Hello,

I know that when setting the Select method of the Grid, additional parameters can be sent to the WCF Service method by hooking to the DataBinding event.

Can I do the same for Update and Delete methods ?

I tried doing in th OnSave event the same thing as in the OnDataBinding event , but did not work.

Any help is greatly appreciated .

Thank you,
Bogdan

4 Answers, 1 is accepted

Sort by
0
Petur Subev
Telerik team
answered on 15 Oct 2012, 03:20 PM
Hello Bogdan,

When you use the Save event of the Grid you can send the values like this:
function onGridSave(e){
    e.values.foo = "test 1";
    e.values.bar = 23;
}


All the best,
Petur Subev
the Telerik team
Check out the successor of Telerik MVC Extensions - Kendo UI for ASP.NET MVC - and deem it for new ASP.NET MVC development.
0
Bogdan Cucosel
Top achievements
Rank 1
answered on 15 Oct 2012, 03:29 PM
Hello Petur,

Yes , but that way , the entity that should be saved , must have those properties.

I would like to have clean POCO classes in my model, and not polute them with properties needed for infrastructure.

I tried somethng like 

function onSave(e) {
    var y = { Entity: e.values, myProperty: "ggg" };
    e.values = y;
}


but this did not solve my problem, because it still sends to the server the edited entity.

The related code on the server side looks like :

public class CrudQueryParameter<T>
{
    public string myProperty { get; set; }
 
    public T Entity { get; set; }
}
 
 
    [OperationContract]
    public GridModel Update(GridState state, CrudQueryParameter<TEntity> value)
    {
        commandService.Execute(new SaveOrUpdateCommand<object> { Entity = value.Entity });
 
        return null;// gridQueryService.ExecuteGridQuery(definition, state);
    }


Do you think something like this could be accomplished in any way ?

Thank you,
Bogdan
0
Petur Subev
Telerik team
answered on 18 Oct 2012, 12:09 PM
Hello again Bogdan,

You do not need to extend your model with such properties. If you send value like this:

function onSave(e){
    e.values.foo = 123;
}

On the server you could append additional argument to the method signature and it will be populated successfully.
public ActionResult Update(string foo, ...)


Kind regards,
Petur Subev
the Telerik team
Check out the successor of Telerik MVC Extensions - Kendo UI for ASP.NET MVC - and deem it for new ASP.NET MVC development.
0
Bogdan Cucosel
Top achievements
Rank 1
answered on 18 Oct 2012, 12:31 PM
Hello Petur,

There must be something wrong. When I do what you say , this is what Fiddler is telling me it is being sent to the client :
<P>{"value":{"Id":"1","Description":"GIBRALTARr","myParameter":"ggg"},"state":{"page":"1","size":"10","groupBy":"","filter":"","orderBy":"","aggregates":""}}</P>

You can see that myParameter is neing sent as a property of value, this is way I was talking about extending the entity.

Is there something I am missing ?
Thank you,
Bogdan
Tags
Grid
Asked by
Bogdan Cucosel
Top achievements
Rank 1
Answers by
Petur Subev
Telerik team
Bogdan Cucosel
Top achievements
Rank 1
Share this question
or