+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Kendo UI Grid using Knockout and OData export data

Kendo UI Grid using Knockout and OData export data

2 posts, 1 answered
  1. David D
    David D avatar
    13 posts
    Registered:
    17 Oct 2013
    31 Mar 2014
    Link to this post

    I have a kendogrid in a custom widget defined that is binding to a div using knockout and using the Transport as OData returning json.

     

    I am trying to get the data out of the grid to use to export it.  I cannot seem to find the way to get that data out.

    Is there a way using Jquery to do this?

    I've tried the following:

    $("#grid").data("kendoGrid");

    $("#grid").data().kendoGrid.dataSource.view()

    both give me undefined. from the data function 

    Seems like there should be a way to get to it using the observable

    Here is the part of my definition :

    <div data-bind="kendoGrid:
                {
                    data: undefined,
    autoBind: false,
    dataSource: {
                        type: 'odata',
                        transport: {
                            read: {
                                url: userSecurityUrl + '/AccountGroups',
                                dataType: 'json'
                            }
                        },

    .........

    </div>

  2. David D
    David D avatar
    13 posts
    Registered:
    17 Oct 2013
    01 Apr 2014
    Link to this post

    I figured it out .. 

     Changed the knockout in my js file to be 

    var cagListDataSource = new kendo.data.DataSource({        
               type: 'odata',
               transport: {
               read: {
                           url: window.userSecurityUrl + '/AccountGroups',
                           dataType: 'json'
               }
               },
           schema: {
               data: function (response) {
                   self.gridIsInCallbackMode(false);
                   return response.Items;
               },

               total: function (response) {
                   return response.Count;
               }
           },
           serverSorting: true,
           serverPaging: true,
           serverFiltering: true,
           pageSize:10
    });
       
    self.cagList = ko.observable(cagListDataSource);

    Then set the dataSource in the grid to simply cagList

     

    this worked.

    Answered
2 posts, 1 answered