This is a migrated thread and some comments may be shown as answers.

[Solved] Grid edit mode fill combobox

5 Answers 152 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Gerard Eikelboom
Top achievements
Rank 1
Gerard Eikelboom asked on 17 Mar 2011, 12:00 PM
Hi,
another thing I have is when I want to fill a combox On edit of the Grid I want to give a variable with it.
So when items are retrieved from the DB in my controller an ID has to come in:

public

 

 

ActionResult _SelectedDefaultWebshopPerUser(string text)

so text needs to be filled with my ID.

 

In my grid I have a datakey with the unique ID can I do something with that?
Here a part of the Grid:
.ClientEvents(events => events.OnRowSelect("onUserRowSelect"))
                    .DetailView(details=> details.ClientTemplate(
                        Html.Telerik().Grid<Fleura.Feelflorist.Models.ViewModels.RegisterViewModel>()
                        .Name("WebshopsUserOverzichtGrid_<#=User_ID#>")
                        .ClientEvents(events => events.OnEdit("onEdit"))
                        .DataKeys(keys => keys.Add(rvm => rvm.User_ID))


Or do I have to create an Client side,AJAX ,event OnDatabound and then give the ID with it to the controller.
Here is my combobox:
<%= Html.Telerik().ComboBox()
    .Name("WebshopsUser")
    .HighlightFirstMatch(true)
    .Filterable(filtering =>
    filtering.FilterMode(AutoCompleteFilterMode.Contains))
    .DataBinding(binding => binding.Ajax()
    .Select("_SelectedDefaultWebshopPerUser", "User").Cache(true))
%>

Regards,
Gerard Eikelboom 

5 Answers, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 19 Mar 2011, 11:05 AM
Hello Gerard,

 
If you need to send additional data to the server you will need to wire OnDataBinding event and extend e.data with the value which you need to send. Check Server Filtering demo, which sends filter mode to the server. If you need to change the value which ComboBox UI component sends to the server you should extend e.data with {text: "your value"}.

As a side note you can change the parameter which is send to the server. By default it is named "text". You can change this option like so:

$('#ComboBox').data("tComboBox").queryString.text = "userID"

Kind regards,
Georgi Krustev
the Telerik team
0
Gerard Eikelboom
Top achievements
Rank 1
answered on 22 Mar 2011, 08:35 AM
Hi Georgi,
I think this is the good way. But How can I get the value of a Client grid column in my OnDataBinding event from my combobox, which is also in the client grid?
 I need this because I want the combobox to be filled with particular data which I only can get when I have the value of the client grid, then sent that value to my controller do a query and put the combobox values back to the combobox.

Regards,

Gerard Eikelboom
 
0
Georgi Krustev
Telerik team
answered on 22 Mar 2011, 08:46 AM
Hello Gerard,

 
It is hard to provide best solution depending on the given information. I will ask you to send us a simple test project which implements the described functionality. Thus I will be able to observe it locally and advice you further.

Kind regards,
Georgi Krustev
the Telerik team
0
Gerard Eikelboom
Top achievements
Rank 1
answered on 22 Mar 2011, 09:05 AM
Hi Georgi,

See enclosed a sample project.
What I mean is.
In my VoorraadController.cs.
method:
public ActionResult _Lengtes(string ClientGridvalue)

When I click on the hidden icon to open the grid. Click on edit mode.
Actually what I want is before I click on the 'Len' dropdown I need the dropdown to be filled with particular data.
So What I thought in first instance to use the onLoad/onOpen event.  I come in my controller method _Lengtes.
And One field of the clientgrid (eg info, country) that value I need to fill the combobox. So that would be my ClientGridvalue in my controller.
In my controller I can (via linq) get the data I need using ClientGridvalue  and return it to the combo.

I hope it helps you a little bit.

Regards,
Gerard
0
Georgi Krustev
Telerik team
answered on 24 Mar 2011, 03:27 PM
Hello Gerard,

 
Thank you for the attached project.

select() client method does not initiate binding of the combobox if it is bound with AJAX. In other words if the component uses AJAX binding, then you should first load items and then select correct one:

function onEdit(e) {
    var combo = $(e.form).find('#lengtes').data('tComboBox');
    combo.fill(function () {
        combo.select(function (dataItem) {
            return dataItem.Text == e.dataItem['S02'];
        });
    });
}


Kind regards,
Georgi Krustev
the Telerik team
Tags
Grid
Asked by
Gerard Eikelboom
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
Gerard Eikelboom
Top achievements
Rank 1
Share this question
or