Getting Started

Prerequistes

In order to use DataContext, you must start by include necessaries libraries to your page :
  • KnockoutJS
  • Knockout.Mapping
  • UnderscoreJS
  • Moment
  • SPATools.Core
  • SPATools.Data

<script type="text/javascript" src="lib/knockout.js" />
<script type="text/javascript" src="lib/knockout.mapping.js" />
<script type="text/javascript" src="lib/underscore.js" />
<script type="text/javascript" src="lib/jquery.js" />
<script type="text/javascript" src="lib/moment.js" />
<script type="text/javascript" src="lib/spatools.core.js" />
<script type="text/javascript" src="lib/spatools.data.js" />

Create your data context

Then, you have to configure your data context. A data context is composed by dataSets which works as table in SQL Databases.

var datacontext = new spa.dataContext();
datacontext.addSet("Contacts");
datacontext.addSet("Products");
datacontext.addSet("Orders");
// ...

var contactsView = datacontext.Contacts.createView();
contactsView.refresh(true);
//-- OR --
datacontext.Contacts.refresh(true);

More information about configuration

Last edited Dec 20, 2012 at 4:02 PM by SomaticIT, version 2

Comments

No comments yet.