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

Web Service- how to add data to context object

6 Answers 221 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Andrew
Top achievements
Rank 1
Andrew asked on 02 Apr 2008, 05:34 AM
When you load on demand from a Web Service, is there a way to add fields to the "context" argument? In my test it contains only "NumberOfItems" and "Text".
Ideally I would like to gather more info about the calling RadCombo. Help anyone?

Thank you
Andrew

6 Answers, 1 is accepted

Sort by
0
Accepted
Nikolay
Telerik team
answered on 02 Apr 2008, 06:12 AM
Hi Andrew,

You can refer to the Populate from WebService example and see how the text of the input field is passed to the context object. The same way you can pass other information about the combobox:

function itemRequesting(sender, eventArgs)
{
var context = eventArgs.get_context();
context["Filter"] = sender.get_text();
}

Hope this helps.

Regards,
Nick
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Andrew
Top achievements
Rank 1
answered on 02 Apr 2008, 09:44 PM
Great, thanks
0
Nesim
Top achievements
Rank 2
answered on 22 May 2008, 09:26 AM
Hi,
I did all like the sample but i get the failed error. No explaining :( 
The HTML Codes:
<telerik:RadComboBox ID="rcbMusteriler" runat="server" CustomText="True" AutoPostBack="False" 
 EmptyMessage="Müşteri Ä°smi Giriniz" EnableLoadOnDemand="True"   
EnableVirtualScrolling="True" LoadingMessage="Arıyor ..." 
 MarkFirstMatch="True" OnSelectedIndexChanged="rcbMusteriler_SelectedIndexChanged"   
OnClientItemsRequesting="itemRequesting" OpenDropDownOnLoad="True">  
    <WebServiceSettings Method="GetMusteriler" Path="Musteriler.asmx" /> 
            <CollapseAnimation Duration="200" Type="OutQuint" /> 
    </telerik:RadComboBox> 
The JavaScript Codes:
<script language="javascript" type="text/javascript">  
    function itemRequesting(sender, eventArgs)  
{  
    var context = eventArgs.get_context();  
    context["Filter"] = sender.get_text();  
}  
</script>  
         
And The WebService Codes:
<Script.Services.ScriptService()> _  
   Public Class WebServiceName  
        Inherits WebService  
        <WebMethod()> _  
        Public Function GetMusteriler(ByVal context As ObjectAs Telerik.Web.UI.RadComboBoxItemData()  
            Dim oDatas(2) As Telerik.Web.UI.RadComboBoxItemData  
            Dim sMstAdi As String = context.ToString  
            If sMstAdi.Length > 2 Then 
                Dim ta As New DataAccess.KULLANICITableAdapters.ButunKullanicilarTableAdapter  
                Dim dt As DataAccess.KULLANICI.ButunKullanicilarDataTable = ta.GetDataByAdSoyad(sMstAdi)  
                ReDim oDatas(dt.Rows.Count - 1)  
                Dim dr As DataAccess.KULLANICI.ButunKullanicilarRow  
                For i As Integer = 0 To dt.Rows.Count - 1 
                    dr = dt.Rows(i)  
                    oDatas(i).Text = dr.ADISOYADI  
                    oDatas(i).Value = dr.KULLANICI_ID  
                Next 
            End If 
            Return oDatas  
        End Function 
    End Class 
0
Veselin Vasilev
Telerik team
answered on 22 May 2008, 11:10 AM
Hello Nesim,

I think that the problem might be related to the fact that you are using context.ToString()

I suggest that you examine these online resources:
I hope this helps.

Sincerely yours,
Veskoni
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Nesim
Top achievements
Rank 2
answered on 22 May 2008, 11:56 AM
Hello Veskoni,
I can't debug it what context returns becasue it doesn't hit when i breakpoint in vs. the event doesn't raise. webservice event.  i tried to convert idictionary the context data. 

Dim dicCon As IDictionary = context
Dim sMstAdi As String = dicCon("Filter").ToString


Nothing different. Same Problem. The server method "GetMusteriler" failed.
I got the text from javascript. 

alert(sender.get_text());


it works ... but i need to more details.

How can i get detailed error exception? Or Stack trace ...

Thanks a lot
0
Veselin Vasilev
Telerik team
answered on 23 May 2008, 03:02 PM
Hi Nesim,

You can subscribe to the OnClientItemsRequestFailed event and examine the error message by calling eventArgs.get_errorMessage() method.

Regards,
Veskoni
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
ComboBox
Asked by
Andrew
Top achievements
Rank 1
Answers by
Nikolay
Telerik team
Andrew
Top achievements
Rank 1
Nesim
Top achievements
Rank 2
Veselin Vasilev
Telerik team
Share this question
or