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

Passing Parameters to a WCF WebGet Method

1 Answer 143 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
Alan
Top achievements
Rank 1
Alan asked on 06 Jul 2012, 04:21 PM
I have created a WCF Data Service that (amongst other things) contains a WebGet Method which accepts a string parameter.  How do I send this parameter from kendoUI Mobile?

WebMethod:

[WebGet]
public IEnumerable<T> GetData(string str)
{
    var linqQuery = from x in Products
                             where productName == str
                             select x;
    return linqQuery;
}

I am trying to call the webmethod as follows:

function GetProduct(name) {
    $("#product-listview").kendoMobileListView({
        dataSource: {
            transport: {
                read: {
                    contentType: "application/json; charset=utf-8",
                    url: "http://ProductDataService.svc/GetData",
                    dataType: "json",
                    data: {param: name }
               }
            },
            schema: {
                data: "d"
            },
            parameterMap: function (options) {
                kendo.ui.progress($("#product-listview"), false);
                return kendo.stringify(options);
            }
        },
        template: $("#product_template").text()
    });
}

This returns no data, and no error. Can anyone help?

1 Answer, 1 is accepted

Sort by
0
Joshua
Top achievements
Rank 1
Veteran
Iron
answered on 17 Aug 2012, 09:49 PM
I am having some trouble when using WebGet. 

If I use operationcontract and do a post i can do the following:
var clinicDS = new kendo.data.DataSource({
    transport: {
        read: {
            url: $.radoloCommon.resolveUrl("~/Services/GetHealthy.svc/ClinicSearchByName"),
            type: "POST",
            contentType: "application/json; charset=utf-8",
            dataType: "json"
        },
        parameterMap: function (options) {
            return kendo.stringify( { NameFilter: $('#clinicSearch').val(),IncludeDisabled:false, Options: options });
        }
    },
    schema: {
        data: "d.Data",
        model: { id: "ID" },
        total: "d.Total"
    },
    pageSize: 10,
    serverPaging: true
});


with the matching wcf info:
public IEnumerable<Model.ClinicInfo> ClinicSearchByName(string NameFilter, bool IncludeDisabled, Radolo.Common.Model.DataSourceServerOptions Options)
 
    public class DataSourceServerOptions
    {
        public int take { get; set; }
        public int skip { get; set; }
        public int page { get; set; }
        public int pageSize { get; set; }
        public object[] group { get; set; }
        public KendoSort[] sort { get; set; }
    }
 
    public class KendoSort
    {
        public string field { get; set; }
        public string dir { get; set; }
    }
Tags
Data Source
Asked by
Alan
Top achievements
Rank 1
Answers by
Joshua
Top achievements
Rank 1
Veteran
Iron
Share this question
or