MDArrayEngine: Javascript Array Class

MDArrayEngine: Javascript Array Class


mdArrayEngine: A free to use Javascript class for multi dimension array creation and manipulation

The MDArrayEngine class provides several functions to create and manipulate multi-dimensional arrays like adding, update, retrieve and delete scalar or array elements, searching for values, sum the element values and display the array values in a HTML page, it should assist you with any Javascript projects incorporating multi dimensional array use.

As MDArrayEngine is a dual MIT & GPL license, please feel free to modify or extend the class. If you feel that others could benefit from your work, please include a message here and your additions to the base class will be included as appropriate.

How to Instantiate:

1. Include the file mdArrayEngine.js in your project.

1
    <script type="text/javascript" src="js/mdArrayEngine.js"></script>

2. in your javascript, instantiate the array class in the following manner:

2
3
4
5
6
7
8
9
10
11
12
13
    <script type="text/javascript">
        // instantiate the object
        var a = KROMOSOME.MDArrayEngine;
        // initialise the object
        a.init();
        // load the array with values
        a.pushValue(['test','try','alerts']);
        // get all array values as a formatted HTML table
        var html = a.arrayDump();
        // output table to document to check values
        document.write(html);
    </script>

List of KROMOSOME.MDArrayEngine functions:

  • init(): Initialize the class array.
  • getLength(): Return the length of the array.
  • getRowLength([int] row): Return the length of the array’s row.
  • pushValue([object] v): Push string or array of values onto the end of the array.
  • rowPush([string] searchValue, [object] addValues): Add items to an existing row where the searchValue matches.
  • indexOfValue([object] v): Return the array indices of the value (string or array) in the array.
  • getValue([int] iRow, [int] iCol): Return a value from the array matching the supplied row and column numbers.
  • setValue([int] iRow, [int] iCol, [object] data): Assign a value to the array matching the supplied row and column numbers.
  • getRow([int] iRow): Return a row from the array matching the supplied row number.
  • getAllValues(): Return the entire contents of the array as an array.
  • updateItem([object] searchVal, [object] replaceVal): Replace the first occurrence of searchVal with replaceVal.
  • upadteRow([object] searchVal, [object] replaceVal): Replace a row in the array on the first match of searchVal.
  • deleteRow([int] row): Delete the row number corresponding to the row variable.
  • updateRow_DualCondition([string] condition1, [string] condition1, [object] updateData): Updates differences in matching row with data from updateData, or inserts a new row if no match found on search condition1 & condition2, returns true for success, false for failure.
  • column_Arithmetic_Sum_SingleCondition([int] conditionalColumn, [object] value, [int] columnToAdd): Sum the values of the columnToAdd WHERE conditionalColumn = x AND conditionalColumn value = y.
  • getJSON(): return the multi dimensional array as a JSON data type.
  • arrayDump(): Display the entire contents of the array as an html table.

Download mdArrayEngine

Example Usage


Facebook Twitter Linkedin Digg Delicious Stumbleupon Email

Search

Contact Us

Kromosome Industries Pty. Ltd.
A.B.N. 13007002182

Melbourne, Australia
12 / 17 Como Avenue
South Yarra, Victoria
Australia 3141
T: 0424 767 060

Tweets

Posting tweet...

Kromosome Smart Software Solutions

Content Management Systems

Customized CMS

There are many open source content management systems available today, enabling customization to your specific needs. We can assist you navigate your way through the maze of available systems and select the most appropriate system for your application.

read more
Kromosome Smart Software Solutions

Mobile Device Application Development

Native App vs. Web App

If you are contemplating a standards compliant web application, or a native application for mobile devices, our expertise in the area of building mobile applications can help you better understand the various platforms, their strengths and weaknesses.

read more
Kromosome Smart Software Solutions

Technobabble

Our Areas of Expertiese

  • HTML / XHTML
  • CSS
  • Javascript / Ajax / jQuery
  • XML / JSON / JSONP
  • Flash (AS3) / Actionscript
  • PHP
  • SQL Database Development
  • CMS & E-Commerce Systems
  • Native Mobile Device Applications

read more
Kromosome Smart Software Solutions

© 2010 Kromosome Industries Pty. Ltd. A.B.N. 13 007 002 182