Cell-Level API

isChecked

indicates whether a checkbox or a radio button is checked

Returns:

  • state - (boolean) returns true, if the first child of the cell is checked. Otherwise, false
mygrid.cells("row1",1).isChecked();

isDisabled

indicates whether the specified cell is disabled by the method setDisabled(). If the setDisabled() method wasn't called for the cell, the method returns 'undefined'.

Returns:

  • mode - (boolean) true, if the cell is disabled, otherwise - false
mygrid.cells("row1",4).setDisabled(true);
...
mygrid.cells("row1",4).isDisabled(); // ->true

getAttribute

checks whether the specified cell has a certain attribute

Parameters:

  • name - (string) the attribute's name
mygrid.cells("row1",1).setAttribute('invalid', true); 
...
mygrid.cells("row1",1).getAttribute('invalid'); // -> true

getBgColor

gets the background color of the cell set by the method setBgColor. If setBgColor() wasn't called for the cell, the method returns ”#FFFFFF”.

Returns:

  • bgcolor - (string) the background color of the cell
//colors the cell in red in 2 different ways
mygrid.cells("row1",1).setBgColor('red'); 
mygrid.cells("row1",3).setBgColor('#ff0000');
...
mygrid.cells("row1",1).getBgColor(); // -> "red"
mygrid.cells("row1",3).getBgColor(); // -> "#ff0000"

getCellCombo

returns dhtmlXCombo cell object that can be used to work with dhtmlxCombo API

Returns:

  • cell_combo - (object) dhtmlXCombo cell object
//getting  dhtmlXCombo cell object
myCombo = grid.cells(id,index).getCellCombo();
 
//using it later with dhtmlxCombo API
myCombo.addOption(key,text);

getHorAlign

retrieves the horizontal alignment set in the cell by the method setHorAlign. If setHorAlign() wasn't called for the cell, the method returns “left”.

Returns:

  • hor_align - (string) the horizontal alignment set in the cell
mygrid.cells("row1",1).setHorAlign('right'); 
...
mygrid.cells("row1",1).getHorAlign(); // -> "right"

getMathValue

gets the math formula specified for the cell. If no formulas are specified for the cell, the method returns the plain cell value.

Returns:

  • math_value - (string) the math formula specified for the cell
mygrid.cells("row1",2).getMathValue(); // returns the value like "=c2*c3"

getTextColor

gets the text color of the cell set by the method setTextColor. If setTextColor wasn't called for the cell, the method returns ”#000000”.

Returns:

  • text_color - (string) the text color of the cell
//colors the cell in red in 3 different ways
mygrid.cells("row1",1).setTextColor('red'); 
mygrid.cells("row1",2).setTextColor('rgb(255,0,0)'); 
mygrid.cells("row1",3).setTextColor('#ff0000');
...
mygrid.cells("row1",1).getTextColor(); // -> "red"
mygrid.cells("row1",2).getTextColor(); // -> "rgb(255,0,0)"
mygrid.cells("row1",3).getTextColor(); // -> "rgb(255,0,0)"

getTitle

gets the value of the specified cell as it's displayed in the grid

Returns:

  • value - (string) the value of the cell as it's displayed in the grid
mygrid.cells("row1",3).getTitle(); // ->"$12.99"
mygrid.cells("row1",3).getValue(); // ->"12.99"

getValue

gets the value of the specified cell

Returns:

  • value (string) - the value of the cell
mygrid.cells("row1",3).getValue(); // ->"12.99"

getWidth

gets the width of the cell in pixels

Returns:

  • width - (number) the width of the cell in pixels
mygrid.cells("row1",3).getWidth();

setAttribute

sets a custom attribute (flag) for the specified cell

Parameters:

  • name - (string) the attribute's name
  • value - (mixed) the attribute's value
mygrid.cells("row1",1).setAttribute('invalid', true); 
...
mygrid.cells("row1",1).getAttribute('invalid'); // -> true

setBgColor

sets the background color for the cell

Parameters:

  • value - (string) the color's value

    Can be specified as:

    • Predefined/Cross-browser color name
    • Hexadecimal color
mygrid.cells("row1",1).setBgColor('red');      // Predefined/Cross-browser color name
mygrid.cells("row1",3).setBgColor('#ff0000');  //Hexadecimal color

setDisabled

disables/enables the cell

Parameters:

  • value - (boolean) the true value disables the cell, the false one - enables
mygrid.cells("row1",2).setDisabled(true);

setHorAlign

sets the horizontal alignment in the cell

Parameters:

  • value - (string) the horizontal alignment

    Possible values are:

    • 'r' or 'right' - the right alignment
    • 'l' or 'left' - the left alignment
    • 'c' or 'center' - the center alignment
mygrid.cells("row1",1).setHorAlign('r');

setTextColor

sets the text color for the cell

Parameters:

  • value - (string) the color value

    Can be specified as:

    • Predefined/Cross-browser color name
    • Hexadecimal color
    • RGB color
mygrid.cells("row1",1).setTextColor('red');      // Predefined/Cross-browser color name
mygrid.cells("row1",3).setTextColor('#ff0000');      // Hexadecimal color
mygrid.cells("row1",2).setTextColor('rgb(255,0,0)'); // RGB color

setValue

sets the value for the specified cell

Parameters:

  • value - (string) the value to set
mygrid.cells("row1",0).setValue("newValue");
Back to top