$.Data.Table( table_structure_json ) - Class
$.Data.Table() allows a Database Table like storage in client (browser) side and it's benefits. This Table functionality has APIs like insert, update, select and remove which are similar to a database table operations. It brings few important features of a Database Table.

$.Data.Table() uses Arrays and JSON formats for data storage. NedilJS internally uses $.Data.Table() for event handling. All Nedil Tables will have and "id" column which will be auto incremented for every insert. This data structure is not suitable for heavy data management and is temporary which will be lost once the page is closed.
Parameters
NameTypeDescription
table_structure_jsonJSONThis JSON lists the fields / columns in $.Data.Table(). All field name should be empty arrays
Eg: var tab = new $.Data.Table( {name:[], age:[], salary:[]} );
Returns
TypeDescription
Object of $.Data.Table()Returns the $.Data.Table() object's reference, methods can be invoked using this reference.
Example
Create a Table with fields 'name', 'age' and 'salary'
JS
		$.domLoaded(function() {
		
			//Create a Table object with name, age and Salary columns
			var tab =  new Nedil.Data.Table({name:[], age:[], salary:[]});
			
		});						
						
.insert( insert_values_json )
insert() is similar to Database tables insert statement. It inserts new record into Nedil Table structure and returns id of new inserted record.
Parameters
NameTypeDescription
insert_values_jsonJSONThis JSON lists the columns and corresponding values which need to be inserted
Eg: tab.insert({name : "Senthil" , age : 24, salary : 2000});
Returns
TypeDescription
New Record ID - NumberReturns "id" of newly inserted record.
Example
Insert two records in Nedil Table.
JS
		$.domLoaded(function() {
		
			//Create a Table object with name, age and Salary columns
			var tab =  new Nedil.Data.Table({name:[], age:[], salary:[]});
			
			//Insert records into the table
			tab.insert({name : "Senthil" , age : 24, salary : 2000});
			tab.insert({name : "Ganesh" , age : 27, salary : 3000});
			
		});						
						
.update( set_values_json , where_cond_json )
update() is similar to Database tables update statement. It sets values provided by first parameter to all records which match the where condition provided as second parameter. It returns number of records updated.
Parameters
NameTypeDescription
set_values_jsonJSONThis JSON lists the columns which need to be updated with new update values
where_cond_jsonJSONThis JSON lists the columns and matching values to select matching records, use "*" for all records
Returns
TypeDescription
NumberReturns number of records updated
Example
Update few records with condtions.
JS
		$.domLoaded(function() {
		
			//Create a Table object with name, age and Salary columns
			var tab =  new Nedil.Data.Table({name:[], age:[], salary:[]});
			
			//Insert records into the table
			tab.insert({name : "Senthil" , age : 24, salary : 2000});
			tab.insert({name : "Ganesh" , age : 27, salary : 3000});
			
			//To update all reocords with salary 3000, use condition as "*"
			var rec = tab.update({salary : 3000}, "*");

			//To update reocords with salary 3000 only for name = "Senthil" condition
			var rec = tab.update({salary : 3000}, {name : "Senthil"});
			
			//Multiple Cond - Set salary=3000 for records with name="Senthil" & age=24
			var rec = tab.update({salary : 3000}, {name : "Senthil", age : 24});
			
			//Multiple values - Set age=24 & salary=3000 for records with name="Senthil"
			var rec = tab.update({age : 24, salary : 3000}, {name : "Senthil"});

			//Multiple values & Multiple Conditions
			var rec = tab.update({age : 25, salary : 3000}, {name : "Senthil", age : 24});
			
		});						
						
.remove( where_cond_json )
remove() is similar to Database tables delete statement. It deletes records from Nedil Table and returns number of records deleted. Where condition can be provided as parameter.
Parameters
NameTypeDescription
where_cond_jsonJSONThis JSON lists the columns and matching values to select matching records, use "*" for all records
Returns
TypeDescription
NumberReturns number of records deleted
Example
Delete few records with condtions.
JS
		$.domLoaded(function() {
		
			//Create a Table object with name, age and Salary columns
			var tab =  new Nedil.Data.Table({name:[], age:[], salary:[]});
			
			//Insert records into the table
			tab.insert({name : "Senthil" , age : 24, salary : 2000});
			tab.insert({name : "Ganesh" , age : 27, salary : 3000});

			//To delete record with name = "Senthil" condition
			var rec = tab.remove({name : "Senthil"});
			
			//Multiple Conditions
			var rec = tab.remove({name : "Senthil", age : 24});

			//To delete all reocords, use condition as "*"
			var rec = tab.remove("*");

		});						
						
.select( column_name_array, where_cond_json )
select() is similar to Database tables select statement. It fetches records from Nedil Table and returns result set as an Array of Rows object. Selection can be limited using where condition.
Parameters
NameTypeDescription
column_name_arrayArrayArray of column names which should be selected
where_cond_jsonJSONThis JSON lists the columns and matching values to select matching records, use "*" for all records
Returns
TypeDescription
Record Set - Array of RowsReturns array of Rows object through which individual values can be retrieved.
Rows - Methods
methodDescription
getValue( column_name )This function is applied to Rows object. It takes column name as input parameter and returns the value of corresponding column for a particular record.
Example
Select records using .select() function and iterate over the result set to get individual records and values.
JS
		$.domLoaded(function() {
		
			//Create a Table object with name, age and Salary columns
			var tab =  new Nedil.Data.Table({name:[], age:[], salary:[]});
			
			//Insert records into the table
			tab.insert({name : "Senthil" , age : 24, salary : 2000});
			tab.insert({name : "Ganesh" , age : 27, salary : 3000});

			//To select all records
			var rs = tab.select("*", "*");
			
			//With conditions
			var rs = tab.select("*", {name : "Senthil", age : 24});
			
			//Restrict columns - Fetch only 'name' and 'age'
			var rs = tab.select(["name", "age"], "*");
			
			//Iterate result set and get values
			for(var i = 0, len = rs.length; i < len; i++) {
				
				//Get name, rs[] is array of Rows object
				var n = rs[0].getValue("name");
				//Get age
				var a = rs[0].getValue("age");
				
			}

		});						
						
Example
Let's put all together and try few opertations like insert, remove, update and select in Nedil.Data.Table()
JS HTML CSS
		$.domLoaded(function() {
		
			// create table structure
			var tab =  new Nedil.Data.Table({name:[], age:[], salary:[]});
			
			// insert few records
			tab.insert({name : "Senthil" , age : 24, salary : 2000});
			tab.insert({name : "Ganesh" , age : 27, salary : 3000});
			tab.insert({name : "Shane" , age : 24, salary : 1000});
			
			
			
			function showView () {
			
				// get all records 
				var rs = tab.select("*", "*");
				$.get("#emp").html("");
				
				for(var i = 0, len = rs.length; i < len; i++ ) {
					var tr = $.get("#emp").addChild("tr");
					
					// individual value and display
					tr.addChild("td", { "text" : rs[i].getValue("id")});
					tr.addChild("td", { "text" : rs[i].getValue("name")});
					tr.addChild("td", { "text" : rs[i].getValue("age")});
					tr.addChild("td", { "text" : rs[i].getValue("salary")});
					
					// individual delete button
					var del = tr.addChild("td").addChild("input", { "type" : "button", "value" : "Delete" });
					(function() {
						var id = rs[i].getValue("id");
						del.on("click", function() {
							var rec = tab.remove({id : id});
							showView();
							alert("Deleted " + rec + " records");
						});
					})();
					
				}
			}
			
			$.get("#add").on("click", function() {
				var nam = $.get("#nam").element().value;
				var ag = parseInt($.get("#ag").element().value);
				var sal = parseInt($.get("#sal").element().value);
				
				// insert new values
				tab.insert({ name : nam, age : ag, salary : sal});
				showView();
				
				$.get("#nam").element().value = "";
				$.get("#ag").element().value = "";
				$.get("#sal").element().value = "";		

				alert("New record is inserted");				
			});
			
			$.get("#upd1").on("click", function() {
			
				// update a record
				var rec = tab.update({ name : "Senthilnathan" }, { name : "Senthil"});
				showView();
				alert("Updated " + rec + " records");
			});
			
			$.get("#upd2").on("click", function() {
			
				// update a record
				var rec = tab.update({ salary : 3000 }, { age : 24 });
				showView();
				alert("Updated " + rec + " records");
			});			
			
			$.get("#del").on("click", function() {
			
				// remove a record
				var rec = tab.remove({age : 24});
				showView();
				alert("Deleted " + rec + " records");
			})
			
			showView();

		});									
<body>
	
	Insert<br/>
	Name : <input type="text" id="nam" /> 
	Age : <input type="text" id="ag" style="width : 50px" /> 
	Salary : <input type="text" id="sal" /> 
	<input type="button" id="add" value="Add" /> 
	
	Update<br/>
	<input type="button" id="upd1" value="Set name to 'Senthilnathan' for record with name 'Senthil'" /> 
	<input type="button" id="upd2" value="Set salary to 3000 for record with age '24'" /> 

	Remove<br/>
	<input type="button" id="del" value="Delete records with age = 24" /> 
	
	Table<br />
	<table id="emp">
	</table>
	
</body>					
					
	table {
		border-collapse: collapse;
	}
	
	table td {
		padding : 5px;
		border : 1px solid #000;
	}
	
	#queue {
		border : 1px solid #555;
		padding : 5px;
	}
Result