Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

Recently I have been using KenoUI with SharePoint.  

Here is how I got a datasource to work with the listdata.svc.

 

  function myDS() {

            var serviceUrl = "_vti_bin/listdata.svc/MyList?$select=Title";
            var dataSource = new kendo.data.DataSource({
            type: "odata",
              transport: {
                read:  {
                  url: serviceUrl,
                  dataType: "json" 
                },
              },
              schema: {
                model: { 
                        Id: "Id",
                        fields: {
                             Title: { type: "string" }
                    }
                }
              },
                error: function (e) {
                    var response = JSON.parse(e.responseText);
                    alert(response.error.message.value);
                }
             });
        return dataSource;
    }

 

However, this was still problematic.  In some cases I reverted to a standard jQuery.ajax call.

Here is an example:

	function loadOData() {
            //Ajax call to load divisions into model
            var serviceUrl = "_vti_bin/listdata.svc/SomeLookupList?$select=Title&$orderby=Order asc";
            var data = new Array();
            $.ajax({
                type: "GET",
                contentType: "application/json",
                dataType: "json",
                url: serviceUrl,
                success: function(result) {
                    //alert(JSON.stringify(result));
                    for(var i = 0; i < result.d.results.length; i++)
                    {
                        data.push({ Title: result.d.results[i].Title });
                    }
                }
            });
        }

The above script is used with a SharePoint list with the following fields:

  • Title
  • Order

The fact that we can place the sorting on the request URL is pretty cool and saves time.

 

  • No labels