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

[Solved] ComboBox - OnEdit Grid

6 Answers 344 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Jigar
Top achievements
Rank 1
Jigar asked on 12 Nov 2010, 12:25 PM
Hi there,

I am using Q3 release 1110 build; I want to select the value in combo box when I edit the record in grid.

I have tried this two ways.
1. I used select in javascript. For Example: comboBox.select(function(item) { return item.value == id });
2. I also tried to bind the combo box again where I select the item in controller method. for example
   
<HttpPost()>
        Public Function _AutoCompleteClientEdit(ByVal id As Integer?) As ActionResult
            Dim myList As New List(Of ComboClass)
            Dim clients = _repository.FindAllClient()
            myList = clients.Select(Function(a) New ComboClass With {.id = a.id, .name = a.code}).ToList()
            Return New JsonResult With {.Data = New SelectList(myList, "id", "name", id)}
        End Function

I also verified the response of this method in firebug, and it's correct. but somehow combo box is not honoring the selected value.

Please help for the same.

Thanks,

Jigar

6 Answers, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 12 Nov 2010, 01:28 PM
Hello Jigar,

Could you please send us a simple test project which reproduces the depicted issue? Thus I will be able to review it locally and advice you further.

All the best,
Georgi Krustev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Jigar
Top achievements
Rank 1
answered on 12 Nov 2010, 02:16 PM
Hi Georgi,

Please find the sample project here.

I am facing new problem in this sample project.

1.  it always says that jquery("#comboList").tComboBox is not a function. This works fine in 930 build.
2.  I have put both the ways I describe in above post in onGridEdit javascript function.

Thanks & Regards,

Jigar.
0
Jigar
Top achievements
Rank 1
answered on 12 Nov 2010, 02:17 PM
oh my mistake, sorry...

Sample project

Regards
0
Georgi Krustev
Telerik team
answered on 17 Nov 2010, 02:39 PM
Hello Jigar,

This is a known issue which is already fixed.
Take a look at this forum thread.

Sincerely yours,
Georgi Krustev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Jigar
Top achievements
Rank 1
answered on 19 Nov 2010, 11:04 AM
Hi Georgi,

Thanks a lot for your reply.

But I am still not able to see the value in combo box while grid editing. I tried to do so in the following ways.

1. tMyTestCombo.select(function (dataItem) { return dataItem.value == "2"; }); 

2. var cUrl = '<%= Url.Action("_StaticDropDownList", "Home")%>';
    $.post(cUrl, { id: 2 }, function (data) { tMyTestCombo.dataBind(data) }, 'json');
<HttpPost()>
    Function _StaticDropDownList(ByVal id As Integer?) As ActionResult
        Dim myList As IList = New List(Of ComboClass)
        'myList = EnumToList(Of Status)()
        myList.Add(New ComboClass With {.id = 1, .name = "TEST-1"})
        myList.Add(New ComboClass With {.id = 2, .name = "TEST-2"})
        myList.Add(New ComboClass With {.id = 3, .name = "TEST-3"})
 
        Return New JsonResult With {.Data = New SelectList(myList, "id", "name", id)}
    End Function

Both the ways are not working for me. You may have a look at the sample project.

Thanks & Regards,

Jigar.
0
Georgi Krustev
Telerik team
answered on 23 Nov 2010, 01:49 PM
Hello Jigar,

After further review of the provided code I noticed that ComboBox UI component is bound with Ajax request. Hence just calling select method will not work. You will need first bind the combobox and then select the correct item. Here is a code snippet showing how to achieve this:
function OnbGridEdit(e) {
    if (e.mode == 'edit') {
        var tMyTestCombo = $('#comboList').data('tComboBox');
        if (tMyTestCombo != undefined)
            tMyTestCombo.fill(function () { tMyTestCombo.select(function (item) { return item.Value == 2; }); });
    }
}

Best wishes,
Georgi Krustev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
ComboBox
Asked by
Jigar
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
Jigar
Top achievements
Rank 1
Share this question
or