This question is locked. New answers and comments are not allowed.
Gerard Eikelboom
Top achievements
Rank 1
Gerard Eikelboom
asked on 18 Mar 2011, 03:00 PM
Hi,
As the title says, I want to delete a client row. Untill now no luck yet.
What I have is A grid in it first name, last name
My client has more properties in it.
in the dataBinding.Ajax.Delete I only can give as variable the first name, last name with it:
But this is not enought because in my client I have some different. What I want is to sent an Id which is known only in the client and not in the (Main)Grid.
Here a piece of my client, what I need to sent to my controller is 'SelectedWebshop' Both grids make use of a different model.
Client:
As test is what I did, I added a property to my main grid. And When I hit delete of the client row I was able to sent that property to my controller.
But that is not what I want. I want to sent the properties of my client grid to the controller. Which seems logical to me.
Hope you can help me out with this.
Regards,
Gerard
As the title says, I want to delete a client row. Untill now no luck yet.
What I have is A grid in it first name, last name
My client has more properties in it.
in the dataBinding.Ajax.Delete I only can give as variable the first name, last name with it:
.Delete("_DeleteUserWebshop", "User", new { User_Id = "<#=User_ID#>", FN = "<#=FirstName#>", LN = "<#=LastName#>" }))But this is not enought because in my client I have some different. What I want is to sent an Id which is known only in the client and not in the (Main)Grid.
Here a piece of my client, what I need to sent to my controller is 'SelectedWebshop' Both grids make use of a different model.
Client:
.DataKeys(keys => { keys.Add(rvm => rvm.User_ID); }) .Editable(editing => editing.Mode(GridEditMode.InLine)) .Footer(false) .Columns(columns => { columns.Bound(rvm => rvm.Voornaam).Width(90).ReadOnly() .HeaderHtmlAttributes(new { title = "First name" }); columns.Bound(rvm => rvm.Achternaam).Width(90).ReadOnly() .HeaderHtmlAttributes(new { title = "Last name" }); columns.Bound(rvm => rvm.SelectedWebshop).Width(150).ReadOnly();But that is not what I want. I want to sent the properties of my client grid to the controller. Which seems logical to me.
Hope you can help me out with this.
Regards,
Gerard
8 Answers, 1 is accepted
0
frederic rybkowski
Top achievements
Rank 1
answered on 18 Mar 2011, 06:21 PM
Gerard ,
tried RouteKey ?
keys.Add(k => k.Id).RouteKey("Inner_Id");
No other idea.
0
Hello Gerard Eikelboom,
Atanas Korchev
the Telerik team
Could you send a sample project? We couldn't understand what the requirement is and what currently does not work as expected.
All the best,Atanas Korchev
the Telerik team
0
Gerard Eikelboom
Top achievements
Rank 1
answered on 22 Mar 2011, 09:30 AM
Hi Atanas,
I think I worked it out.
I need you to think a second with me, just to know I am doing it correct.
To delete the client row in my gridI have in my detailview this column:
The .ClientTemplate I put that in later. Just to retrieve the value into my controller.
In my controller I have:
This is how I got the userwebshop value into my controller.
Is this the way?
What I have now is when I open the clientgrid this field is editable. Not very nice. When I put disabled=disabled in my .Clienttemplate The userwebshop in my controller = null.
So if this is the correct way to retrieve 'SelectedWebshop' value, am I able to make this field not editable?
Regards,
Gerard Eikelboom
I think I worked it out.
I need you to think a second with me, just to know I am doing it correct.
To delete the client row in my gridI have in my detailview this column:
The .ClientTemplate I put that in later. Just to retrieve the value into my controller.
columns.Bound(rvm => rvm.SelectedWebshop).Width(150).ReadOnly() .ClientTemplate("<input type='text' name='userwebshop' value='<#=SelectedWebshop#>' />");In my controller I have:
public ActionResult _DeleteUserWebshop(string User_Id, int UserDefaultWebshop, string userwebshop)This is how I got the userwebshop value into my controller.
Is this the way?
What I have now is when I open the clientgrid this field is editable. Not very nice. When I put disabled=disabled in my .Clienttemplate The userwebshop in my controller = null.
So if this is the correct way to retrieve 'SelectedWebshop' value, am I able to make this field not editable?
Regards,
Gerard Eikelboom
0
Hello Gerard Eikelboom,
I hope this helps,
Atanas Korchev
the Telerik team
If you make this field hidden it won't be editable and still the value should be posted as expected:
columns.Bound(rvm => rvm.SelectedWebshop).Width(150).ReadOnly() .ClientTemplate("<input type='hidden'name='userwebshop' value='<#=SelectedWebshop#>' />");Atanas Korchev
the Telerik team
0
Gerard Eikelboom
Top achievements
Rank 1
answered on 22 Mar 2011, 09:55 AM
Atanas,
I want it to be visisble but not editable.
Only when I click on the edit button. So users can change the name. Now it is standard editable.
Regards,
Gerard
I want it to be visisble but not editable.
Only when I click on the edit button. So users can change the name. Now it is standard editable.
Regards,
Gerard
0
Hello Gerard Eikelboom,
If I understand you correctly you want to send one more field to your controller method. Perhaps adding another DataKey would help:
DataKeys(keys=>
{
keys.Add(c => c.Key1); // will be sent as "id" parameter
keys.Add(c => c.Key2).RouteKey("id2"); //we be sent as id2 parameter
});
This will work of the field which needs to be send is exposed by the object you are editing.
Atanas Korchev
the Telerik team
By default disabled input elements are not submitted by the browser. If you can perhaps try to make it readonly:
columns.Bound(rvm => rvm.SelectedWebshop).Width(150).ReadOnly() .ClientTemplate("<input type='text' readonly="readonly" name='userwebshop' value='<#=SelectedWebshop#>' />");If I understand you correctly you want to send one more field to your controller method. Perhaps adding another DataKey would help:
DataKeys(keys=>
{
keys.Add(c => c.Key1); // will be sent as "id" parameter
keys.Add(c => c.Key2).RouteKey("id2"); //we be sent as id2 parameter
});
This will work of the field which needs to be send is exposed by the object you are editing.
Atanas Korchev
the Telerik team
0
Gerard Eikelboom
Top achievements
Rank 1
answered on 24 Mar 2011, 12:00 PM
Hi Atanas,
I added another Key like you said:
keys.Add(c => c.Key2).RouteKey("id2"); //we be sent as id2 parameter
in my controller it comes in as 'id2' but it is null?
Am I missing something?
regars,
Gerard
I added another Key like you said:
keys.Add(c => c.Key2).RouteKey("id2"); //we be sent as id2 parameter
in my controller it comes in as 'id2' but it is null?
Am I missing something?
regars,
Gerard
0
Gerard Eikelboom
Top achievements
Rank 1
answered on 24 Mar 2011, 01:20 PM
Problem solved.
Reason why: didn't fill id2 in my model.
My bad,
Gerard Eikelboom
Reason why: didn't fill id2 in my model.
My bad,
Gerard Eikelboom