How to create data model for Odata web services to enable CRUD operarions in grid

Thread is closed for posting
22 posts, 1 answers
  1. Marko
    Marko avatar
    12 posts
    Member since:
    Apr 2009

    Posted 20 Jan 2012 Link to this post

    Hi,

    I found this documentation for information to create KendoUI grid with CRUD operations. It seems that there is Product model behind this. But I did not find any information or examples about how to create kendo.data.model for remote data (Odata service).  Could anyone help with this?

    read:   "/Products",
             update: {
                url: "/Products/Update",
                type: "POST"
             },
             destroy: {
                 url: "/Products/Destroy",
                 type: "POST"
              },
              create: {
                  url: "/Products/Create",
                  type: "POST"
               }

    BR
    Marko
  2. Nikolay Rusev
    Admin
    Nikolay Rusev avatar
    2289 posts

    Posted 23 Jan 2012 Link to this post

    Hello Marko,

    Currently CRUD operations with OData is not supported. We are working on solution that will allow CRUD operations with OData services.

    All the best,
    Nikolay Rusev
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  3. Marko
    Marko avatar
    12 posts
    Member since:
    Apr 2009

    Posted 23 Jan 2012 Link to this post

    Hi,

    Nice to hear that. What is expected time frame for this Odata CRUD support?

    How CRUD operations to remote data is implemented in this demo case, is there web service behind?

     
    BR
    Marko
  4. Answer
    Nikolay Rusev
    Admin
    Nikolay Rusev avatar
    2289 posts

    Posted 25 Jan 2012 Link to this post

    Hello Marko,

    You can find sample app implemented on the link bellow:
    https://github.com/telerik/kendo-examples-asp-net

    Greetings,
    Nikolay Rusev
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  5. Elan
    Elan avatar
    7 posts
    Member since:
    Nov 2011

    Posted 17 Mar 2012 Link to this post

    Any updates on when OData CRUD will be available?
  6. Atanas Korchev
    Admin
    Atanas Korchev avatar
    8462 posts

    Posted 19 Mar 2012 Link to this post

    Hello,

     OData CRUD will be supported in the next official release - Q1 2011.

    Regards,
    Atanas Korchev
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  7. Elan
    Elan avatar
    7 posts
    Member since:
    Nov 2011

    Posted 19 Mar 2012 Link to this post

    Atanas,

    Do you mean Q1 2012?
  8. Atanas Korchev
    Admin
    Atanas Korchev avatar
    8462 posts

    Posted 19 Mar 2012 Link to this post

    Hi,

     Of course. I meant Q1 2012. It seems I am still living in the past :)

    Regards,
    Atanas Korchev
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  9. Elan
    Elan avatar
    7 posts
    Member since:
    Nov 2011

    Posted 19 Mar 2012 Link to this post

    Can you confirm that  this functionality available in the beta?

    From what I can tell, it is not. :(
  10. Atanas Korchev
    Admin
    Atanas Korchev avatar
    8462 posts

    Posted 19 Mar 2012 Link to this post

    Hi,

     No it is not supported in the beta.

    Regards,
    Atanas Korchev
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  11. Ryan Lege
    Ryan Lege avatar
    42 posts
    Member since:
    Sep 2008

    Posted 10 Sep 2012 Link to this post

    What is the latest on this? I have Q2 installed and I have seen no documentation on how to implement ODATA CUD.
  12. Atanas Korchev
    Admin
    Atanas Korchev avatar
    8462 posts

    Posted 10 Sep 2012 Link to this post

    Hello,

     OData CRUD is now supported. There is a demo project here: https://github.com/telerik/kendo-examples-asp-net/tree/master/grid-odata-crud 

    Regards,
    Atanas Korchev
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  13. Ryan Lege
    Ryan Lege avatar
    42 posts
    Member since:
    Sep 2008

    Posted 12 Sep 2012 Link to this post

    I cannot for the life of me get the CUD to work, only the Read. No transaction takes place against the DB through ODATA. I followed the example exactly.
  14. Atanas Korchev
    Admin
    Atanas Korchev avatar
    8462 posts

    Posted 13 Sep 2012 Link to this post

    Hello,

     We can't really help without seeing some code.

    All the best,
    Atanas Korchev
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  15. Ryan Lege
    Ryan Lege avatar
    42 posts
    Member since:
    Sep 2008

    Posted 13 Sep 2012 Link to this post



    <div id="example" class="k-content">
        <div id="gridPaxEdit"></div>
        <script>
            $(document).ready(function () {
                var crudServiceBaseUrl = DataService + "/EventPaxBreakDowns",
                    
                dataSource = new kendo.data.DataSource({
                    type: "odata",
                    transport: {
                        read: {
                            url: crudServiceBaseUrl,
                            dataType: "jsonp",
                            data: {                  
                                $expand: "Country"
                            }
                        },
                        update: {
                            url: function (data) {
                                return crudServiceBaseUrl + "(" + data.PaxBDID + ")";
                            }
                        },
                        create: {
                            url: crudServiceBaseUrl
                        },
                        destroy: {
                            url: function (data) {
                                return crudServiceBaseUrl + "(" + data.PaxBDID + ")";
                            }
                        }


                    },
                    filter: { filters: [{ field: "EventID", operator: "eq", value: parseInt($("#EventId").val()) }]},
                    serverPaging: true,
                    batch: false,


                    schema: {
                        model: {
                            id: "PaxBDID",
                            fields: {
                                PaxBDID: { editable: false, nullable: true },
                                EventID: { type: "number" },
                                
                                MilitaryPlanned: { type: "number" },
                                MilitaryActual: { type: "number" },
                                CivilianPlanned: { type: "number" },
                                CivilianActual: { type: "number" },
                                Country: {}
                            }
                        }
                            
                    }
                });


                $("#gridPaxEdit").kendoGrid({
                    dataSource: dataSource,
                    height: 250,
                    pageable: true,
                    toolbar: ["create"],
                    columns: [
                        {
                            field: "Country",
                            template: "#=Country.Title#",
                            editor: PaxCountryDropDown
                        }, {
                            field: "MilitaryPlanned",
                            title: "Military Planned"


                        }, {
                            field: "MilitaryActual",
                            title: "Military Actual"


                        }, {
                            field: "CivilianPlanned",
                            title: "Civilian Planned"
                        }, {
                            field: "CivilianActual",
                            title: "Civilian Actual"
                        },
                        { command: ["edit", "destroy"], title: "&nbsp;", width: "210px" }
                    ]


                    ,
                    editable: "inline"


                });


                function PaxCountryDropDown(container, options) {
                    $('<input data-text-field="Title" data-value-field="CountryID"/>')
                    .appendTo(container)
                    .kendoComboBox({
                        dataType: 'json',
                        dataTextField: "Title",
                        dataValueField: "CountryID",
                        autoBind: false,
                        minLength: "1",
                        suggest: true,
                        highLightFirst: true,
                        filter: "startswith",
                        dataSource: {
                            transport: {
                                read: "/_LoadCountryData"
                            },
                            serverFiltering: true
                        }
                    });
                }
            });          
        </script>
    </div>


    Side note: I really would like to to Load On demand through ODATA with the Combobox I have as well.
  16. Atanas Korchev
    Admin
    Atanas Korchev avatar
    8462 posts

    Posted 13 Sep 2012 Link to this post

    Hi Benjamin,

     What exactly happens when say an update operation is executed? Do you see any JavaScript errors in your browser development tools console? Did you check what the response of the HTTP request is? 

     On a side note make sure your page and OData service are in the same domain. Cross-domain OData requests will not work because you cannot perform OData CUD via JSONP.

    Regards,
    Atanas Korchev
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  17. Ryan Lege
    Ryan Lege avatar
    42 posts
    Member since:
    Sep 2008

    Posted 13 Sep 2012 Link to this post

    Fiddler reports the initial read, but after that if one tries to edit or delete or even create nothing happens. The Grid delete and edit respond but visually but nothing is actually transacting, and fiddler shows no activity. The Add button does not even respond. I should tell you that this grid is sitting inside a Kendo Window that is opened when the end user clicks a button on the main page. Also it is in the same Domain 
  18. Atanas Korchev
    Admin
    Atanas Korchev avatar
    8462 posts

    Posted 13 Sep 2012 Link to this post

    Hello,

    I am out of ideas. Does the github project work as expected at your side? Could you modify it so it mimics your own scenario which does not work?

    All the best,
    Atanas Korchev
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  19. Ryan Lege
    Ryan Lege avatar
    42 posts
    Member since:
    Sep 2008

    Posted 13 Sep 2012 Link to this post

    I am attempting to run a test project with the identical GIT example. In the meantime, are you sure that rendering the grid in a KendoWindow is not hindering it from making a ODATA CRUD call?


    ///FINAL UPDATE

    The github example is not doing CUD at all. It is behaving the same as my project. Any ideas folks??
  20. Ryan Lege
    Ryan Lege avatar
    42 posts
    Member since:
    Sep 2008

    Posted 13 Sep 2012 Link to this post

    A CLUE DISCOVERED: Having debugged the github example with fiddler, it seems then when reading the data the the "JSONPSupportBehavior" is getting applied correctly. When attempting Delete Create or Update fiddler is showing a error of :
    "A supported MIME type could not be found that matches the content type of the response. None of the supported type(s) 'application/atom+xml;type=entry, application/atom+xml, application/json;odata=verbose' matches the content type 'application/json'."

    I was under the impression that JSONPSupportBehavior was supposed to take care of this both directions?
  21. Ryan Lege
    Ryan Lege avatar
    42 posts
    Member since:
    Sep 2008

    Posted 14 Sep 2012 Link to this post

    What is the latest on this? I really would like to see this resolved. Thanks
  22. Nikolay Rusev
    Admin
    Nikolay Rusev avatar
    2289 posts

    Posted 17 Sep 2012 Link to this post

    Hello Benjamin,

    I am afraid that we are not able to determine what is wrong with your project. Kendo DataSource supports only JSON for response when binding to OData.

    I am attaching the project from the GitHub library. Seems to be perfectly execute all CRUD operations on our end.

    Regards,
    Nikolay Rusev
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Back to Top