HTML OData Query Builder -
i developed odata web services exposes entity framework model, need develop query builder this,
http://odata.intel.com/querybuilder
are there html or js plugin use, open jquery or angularjs, bootstrap or other plugin available instead of recreating wheel.
var url = 'https://services.odata.org/v4/northwind/northwind.svc'; var builder = new xrm.odata.querybuilder(url) .setentity('orders') .setcolumns('orderid,customerid,shipcountry') .setexpand('order_details') .setfilters(new xrm.odata.filterinfo({ filtertype: xrm.odata.filtertypes.and, filterexpressions: [ "shipcountry eq 'sweden'", 'orderid lt 10800' ], filters: [ new xrm.odata.filterinfo({ filtertype: xrm.odata.filtertypes.or, filterexpressions: [ "customerid eq 'bergs'", 'orderid gt 10700' ], filters: [], }), ] })) .setorders([ new xrm.odata.ordercolumn({ column: 'customerid', order: xrm.odata.ordertypes.asc }), new xrm.odata.ordercolumn({ column: 'orderid', order: xrm.odata.ordertypes.desc }) ]) .setskip(10) .settop(5); var querystring = builder.getqueryfilterspart(); console.log(querystring);
<script src="http://yourjavascript.com/58162111474/odata-querybuilder-0-1-min.js"></script>
result: $select=orderid,customerid,shipcountry&$expand=order_details&$filter=(shipcountry eq 'sweden') , (orderid lt 10800) , ((customerid eq 'bergs') or (orderid gt 10700))&$orderby=customerid,orderid desc&$skip=10&$top=5
- https:// odatasamples.codeplex .com/releases/view/115752
this 1 generates html ui based on service metadata. can customize according needs modifying it. after download , before run, modify "datajs-1.1.1.js", line 2593:
from
xhr.open(request.method || "get", url, true, request.user, request.password;
to
xhr.open(request.method || "get", "https:// cors-anywhere.herokuapp .com/" + url, true, request.user, request.password);
** bug fix (http:// stackoverflow .com/questions/30318371/northwind-odata-service-not-working)
Comments
Post a Comment