有关创建Breeze.js DataAdapter的文档

时间:2013-09-06 00:21:06

标签: breeze

我正试图让Breeze.js与sharepoint交谈。有没有人知道有关如何创建自定义Breeze.js DataAdapter的任何文档?

2 个答案:

答案 0 :(得分:1)

我们希望在下个月左右有更多关于将Breeze与Sharepoint端点连接的指导和文档。这项工作目前正在进行中。所以请继续关注。

答案 1 :(得分:1)

您可以通过oData轻松与sharepoint对话。您需要datajs为breeze添加oData支持并记下对breeze.config.initializeAdapterInstances({ dataService: "OData" });的调用。见下文。

<script src="scripts/jquery-1.8.3.min.js"></script>
<script src="scripts/knockout-2.3.0.js"></script>
<script src="scripts/q.js"></script>
<script src="scripts/datajs-1.1.1.min.js"></script>
<script src="scripts/breeze.debug.js"></script>
<script src="scripts/jquery-ui-1.9.1.custom.min.js"></script>
<script src="scripts/koGrid-2.1.1.js"></script>
<script type="text/javascript">

var my = {}; //my namespace
$(function () {
    var serverAddress = "../_vti_bin/listdata.svc/";
    breeze.config.initializeAdapterInstances({ dataService: "OData" });
    var manager = new breeze.EntityManager(serverAddress);


    my.vm = {
        customers: ko.observableArray([]),
        load: function () {
            var query = breeze.EntityQuery.from("YourSPListHere").take(15);
            manager.executeQuery(query, function (data) {
                var results = data.results;
                my.vm.customers(results);
            });
        }
    }  
    my.vm.load();
    ko.applyBindings(my.vm);              
});      
</script>