Zebra API Doc

zebra.data.Matrix Class

Matrix model class.

Constructor

zebra.data.Matrix

(
  • [data]
  • [rows]
  • [cols]
)

Parameters:

  • [data] Array of Array optional

    the given data

  • [rows] Integer optional

    a number of rows

  • [cols] Integer optional

    a number of columns

Methods

get

(
  • row
  • col
)
Object

Get a matrix model cell value at the specified row and column

Parameters:

  • row Integer

    a cell row

  • col Integer

    a cell column


Return: Object

matrix model cell value

put

(
  • row
  • col
  • obj
)

Set the specified by row and column cell value. If the specified row or column is greater than the matrix model has the model size will be adjusted to new one.

Parameters:

  • row Integer

    a cell row

  • col Integer

    a cell column

  • obj Object

    a new cell value

puti

(
  • i
  • obj
)

Set the specified by index cell value. The index identifies cell starting from [0,0] cell till [rows,columns]. If the index is greater than size of model the model size will be adjusted to new one.

Parameters:

  • i Integer

    a cell row

  • obj Object

    a new cell value

rellocate

(
  • r
  • c
)
private

Reallocate the matrix model space with the new number of rows and columns

Parameters:

  • r Integer

    a new number of rows

  • c Integer

    a new number of columns

removeCols

(
  • begcol
  • count
)

Remove specified number of columns from the model starting from the given column.

Parameters:

  • begcol Integer

    a start column

  • count Integer

    a number of columns to be removed

removeRows

(
  • begrow
  • count
)

Remove specified number of rows from the model starting from the given row.

Parameters:

  • begrow Integer

    a start row

  • count Integer

    a number of rows to be removed

setCols

(
  • cols
)

Set the given number of columns the model has to have.

Parameters:

  • cols Integer

    a new number of columns

setRows

(
  • rows
)

Set the given number of rows the model has to have.

Parameters:

  • rows Integer

    a new number of rows

setRowsCols

(
  • rows
  • cols
)

Set the given number of rows and columns the model has to have.

Parameters:

  • rows Integer

    a new number of rows

  • cols Integer

    a new number of columns

sortCol

(
  • col
  • [f]
)

Sort the given column of the matrix model

Parameters:

  • col Integer

    a column to be re-ordered

  • [f] Function optional

    an optional sort function. The name of the function is grabbed to indicate type of the sorting the method does. For instance: "descent", "ascent".

Attributes

cols

Integer readonly

Number of columns in the matrix model

rows

Integer readonly

Number of rows in the matrix model

Events

cellModified

Fired when the matrix model cell has been updated.

     matrix.bind(function cellModified(src, row, col, old) {
        ...
     });

Event Parameters:

  • src zebra.data.Matrix

    a matrix that triggers the event

  • row Integer

    an updated row

  • col Integer

    an updated column

  • old Object

    a previous cell value

matrixResized

Fired when the matrix model size (number of rows or columns) is changed.

    matrix.bind(function matrixResized(src, pr, pc) {
       ...
    });

Event Parameters:

  • src zebra.data.Matrix

    a matrix that triggers the event

  • pr Integer

    a previous number of rows

  • pc Integer

    a previous number of columns

matrixSorted

Fired when the matrix data has been re-ordered.

      matrix.bind(function matrixSorted(src, sortInfo) {
         ...
      });

Event Parameters:

  • src zebra.data.Matrix

    a matrix that triggers the event

  • sortInfo Object

    a new data order info. The information contains:

     { 
        func: sortFunction,
        name: sortFunctionName,
        col : sortColumn
     }