Archive

Archive for October, 2014

Extjs4 tree (un)check all children

October 20th, 2014 No comments

If you use Extjs treePanel with checkbox to select elements, here’s the solution how to check/decheck all tree elements.

Example for check:

Ext.getCmp('tree-list').getRootNode().cascade(function(n) 
{
    n.set("checked",true); 
});

Example for uncheck:

Ext.getCmp('tree-list').getRootNode().cascade(function(n) 
{
    n.set("checked",false); 
});
Categories: JavaScript Tags: ,

Extjs change grid cell background based on value

October 20th, 2014 No comments

If you want to change the color of a Grid cell Grid, use the renderer attribute.
Example: Suppose you have a cell that has a numeric value. If this value is greater than 0, then the background color is green, otherwise it is red.
Here’s a code that describes:

renderer : function(v, md) 
{
    if(parseInt(v) > 0)
        md.style = "background-color:green;";
    else
        md.style = "background-color:red;";
}