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

Not Calling WebApi Service

1 Answer 50 Views
Grid
This is a migrated thread and some comments may be shown as answers.
CARLOS
Top achievements
Rank 1
CARLOS asked on 22 Apr 2014, 06:51 PM
I have a controller that returns an HttpResponseMessage.

public HttpResponseMessage Get()
{
    return GetByEnteredDate(Convert.ToDateTime("10/16/2013"));
}
 
public HttpResponseMessage GetByEnteredDate(DateTime enteredDate)
{
    return GetByEnteredDates(enteredDate.Date, enteredDate.Date.Add(new TimeSpan(23, 59, 0)));
}
 
public HttpResponseMessage GetByEnteredDates(DateTime fromDate, DateTime thruDate)
{
    var licenses =
        (from li in repository.All
         where !li.Deleted
         && li.DateEntered >= fromDate
         && li.DateEntered <= thruDate
         select li).ToList();
 
    if(licenses != null && licenses.Any())
    {
        return Request.CreateResponse<IEnumerable<LicenseDto>>(HttpStatusCode.OK,
            mapper.Map<IEnumerable<Hialeah.License.Domain.License>, IEnumerable<LicenseDto>>(licenses));
    }
 
    throw new HttpResponseException(HttpStatusCode.NotFound);
}

I then create a simple page and try to load a grid. For the life of me, I have not been able to make it work. I know the service returns data. But I can't even see the call in Google chrome. It just shows the grid with no data. I have tried many combinations in the schema. I place a break point on the Get() method and it doesn't get there. :-(

<div id="licensesGrid"></div>
 
<script type="text/javascript">
 
    $(document).ready(function () {
 
        var licenseDataSource = new kendo.data.DataSource({
            transport: {
                read: {
                    url: "api/licenses",
                    datatype: "json"
                }
            },
            schema: {
                data: function (response) {
                    return response.Data;
                }
            },
            pageSize: 10
        });
 
        $("#licensesGrid").kendoGrid({
            datasource: licenseDataSource,
            pageable: true,
            sortable: true
        });
 
    });
 
 
</script>

Thank you so much,
Carlos

1 Answer, 1 is accepted

Sort by
0
Petur Subev
Telerik team
answered on 24 Apr 2014, 01:13 PM
Hello Carlos,

The dataSource option of the Grid should be typed with capital S.

$("#licensesGrid").kendoGrid({
    dataSource: licenseDataSource,
    pageable: true,
    sortable: true
});


Regards,
Petur Subev
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
CARLOS
Top achievements
Rank 1
Answers by
Petur Subev
Telerik team
Share this question
or