JDataset : A Simple Javascript ORM Framework

Provide client side data modeling, pure javascript recordset. Simplified data manipulation and Ajax interaction.

  • Less than 10k after minified
  • No external dependencies
  • No modification to built in objects
  • AJAX included

What does JDataset code look like? Here's the quick view:

	var ds = new JDataset(); 
    var div = document.getElementById("demo");
	ds.loadFromJSON({
    	url:"data/customer.json",
        onSuccess: function() {
        	ds.showTable("demo");
         },
        onProcess: function() {
        	div.innerHTML = "";
        }
    }); 			
    

Run Code


JDataset Framework

JDataset Features

Represents as tabular form, object-oriented visiting

You can treat JDataset as a Recordset with less restriction than traditional dataset. Add field dynamically. Get/Set field value by field name. You can even contain JDataset as a field.

	val customer = new JDataset("customer");
    customer.append();
    customer.setVal("Name", "John");
    customer.setVal("Age", 35);
    customer.append();
    customer.setName("Tom");
    customer.setAge(40);
    
    customer.foreach(function(ds) {
    	alert( customer.Name() + " is " + customer.Age);
    });

XML/JSON loading by AJAX. JSON posting by AJAX

Simplifies AJAX coding. Load data from JSON/XML by configurating the ajaxParam parameter in loadFromJSON/loadFromXML/post function, you can set synchronization or asynchronization flag, HTTP request type, and onSend/onError/onSuccess/onCustom/onProcess event handle.


Sample code 1: represent how to get an asynchronous JSON data from server.

  var ds1 = new JDataset("ds");
  ds1.loadFromJSON( {
  	url : "data/language.json",
 	onSuccess : function(xhr) {
  		//ds1.foreach(…);
  	}
  });

Sample code 2: represent how to get an asynchronous XML data from server.

  var ds1 = new JDataset("ds");
  ds1.loadFromXML( {
  	url : "data/book",
  	onError:  function(code, msg) {
  		//do something;
  	},
 	 onSuccess : function(xhr) {
  		//ds1.foreach(…);
  	}
  });  

Sample code 3: Marshalling JDataset to JSON format automatically and post to the server asynchronously.

  var ds1 = new JDataset();
  ds1.append();
  ds1.setVal("name", "John");
  ds1.post( {
  	url : "http://localhost:8080/custom/datahandle",
  	onSuccess : function(xhr) {
		// xhr.responseText;
  	}
  });

Sample code :Sample for JDataset AJAX loading , Sample for JDataset AJAX posting

See also : loadFromXML, loadFromJSON, post


Rich data manipulation: CRUD, navigation, locate, filter, etc.

As a recordset/dataset, JDataset privide navigation function to explorer data, Locate special record via values, extract subdataset with filter function.


Sample code :Sample for JDataset CRUD, Sample for JDataset navigator, Sample for JDataset filter, Sample for JDataset locate

See also : first, last, next, previous, eof, bof, locate, filter


JDataset

Lastest version: v1.2

(25-June-2010)


Bookmark and Share