This document provides a reference example based on the Code. msdn example,CodePlaced in:
Http://dskit.codeplex.com
To access the WCF data service using JavaScript in the Asp.net MVC application, the following is an example of using the Microsoft Ajax library for processing.
var datacontext;
var queryobject, queryobject1;
sys. require ([sys. components. dataview, sys. components. adonetdatacontext]);
// run the command
sys. onready (function () {
datacontext = sys. create. adonetdatacontext (
{< br> serviceuri: "/services/northwindservice. SVC ",
mergeoption: SYS. data. mergeoption. appendonly
});
datacontext. initialize ();
queryobject = new sys. data. adonetquerybuilder ("customers");
queryobject. set_orderby ("contactname"); // $ orderby
queryobject. set_filter ("city EQ" + "'London"); // $ filter
queryobject. set_expand ("orders"); // $ expand
queryobject1 = new sys. data. adonetquerybuilder ("customers");
queryobject1.set _ filter ("startswith (companyName, 'A')");
});
<Body xmlns: dataview = "javascript: SYS. UI. dataview" xmlns: SYS = "javascript: SYS">
<Table>
<Tr class = "tableheader">
<TD>
ID
</TD>
<TD>
Name
</TD>
<TD>
Contact
</TD>
<TD>
# Orders
</TD>
</Tr>
<Tbody SYS: attach = "dataview" class = "sys-template" dataview: dataprovider = "{datacontext }}"
Dataview: fetchoperation = "{queryobject. tostring ()}" dataview: autofetch = "true">
<Tr>
<TD>
{Customerid }}
</TD>
<TD>
{CompanyName }}
</TD>
<TD>
{Contactname }}
</TD>
<TD>
{Orders. Length }}
</TD>
</Tr>
</Tbody>
</Table>
The above code is in the upper part.
It is a demonstration of three scenarios: Table display, query, and Master/Slave tables. It can be seen that the client script library of Ms Ajax has powerful functions.
Face-to-Face table display can be customized using CSS control. Of course, there are also many frame libraries, such as jqgrid in jquery.
If you are integrated with Asp.net, you can use jqmvcgrid