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

Read Parameters for Kendo crud Read Service.

1 Answer 107 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Chatra
Top achievements
Rank 1
Chatra asked on 16 May 2014, 08:41 PM
Hi,

I am able to Read/Get the list of items with Crud Read. But I am not able to pass the parameter to get a list of items through crud Read.Please see below demo(writer.js ;line 304)

function BuildAgentGrid(model) {
 
    var crudServiceBaseUrl = window.applicationBaseUrl + 'api/WebApi';
 
    agentdataSource = new kendo.data.DataSource({
        transport: {
            read: {
                url: crudServiceBaseUrl + "/GetAgentbyWriterIDData/",
                data: { WriterModel: model },
                contentType: "application/json"
            },
            parameterMap: function (options, operation) {
                if (operation == "read") {
                    return kendo.stringify(options.WriterModel);
                }
            }
        },
        batch: true,
        pageSize: 10,
        serverPaging: true,
        serverFiltering: false,
        serverSorting: true,
        schema: {
            model: {
                AgentID: "AgentID",
                Name: "Name",
                IsActive: "IsActive",
                fields: {
                    AgentID: { type: "string" },
                    Name: { type: "string", validation: { required: true} },
                    IsActive: { type: "boolean" }
                }
            }
        },
        filter: {
            "field": "IsActive",
            "operator": "IsEqualTo",
            "value": true
        }
    });

I am trying to send full object of writer(on edit) and take writerID to get list of Agents on popup agents tab.

//Web Api Controller
 //param:Data :Expected full object of WriterModel on Edit as parameter
        public List<Agent> GetAgentbyWriterIDData(Object Data)
        {
            //Get writerID from data object and pass writerID to get list of AgentList
 
            //trying to return the Agent list based on writerID of WriterModel;
            return null;
        }

Thanks,
Chatrapathi Chennam

1 Answer, 1 is accepted

Sort by
0
Alexander Popov
Telerik team
answered on 20 May 2014, 01:19 PM
Hi Chatrapathi,

This could be achieved by using an argument with a matching name and type. For example: 
agentdataSource = new kendo.data.DataSource({
    transport: {
    read: {
        url: crudServiceBaseUrl + "/GetAgentbyWriterIDData/",
        data: { WriterID: model.WriterID },
...
 
public List<Agent> GetAgentbyWriterIDData(int WriterID)
{
   ...
}
Another approach would be to pass the entire model and use a strongly typed argument: 
agentdataSource = new kendo.data.DataSource({
    transport: {
    read: {
        url: crudServiceBaseUrl + "/GetAgentbyWriterIDData/",
        data: { WriterModel: model.toJSON() },
...
 
public List<Agent> GetAgentbyWriterIDData(WriterViewModel WriterModel)
{
    return null;
}


Regards,
Alexander Popov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Grid
Asked by
Chatra
Top achievements
Rank 1
Answers by
Alexander Popov
Telerik team
Share this question
or