PDA

View Full Version : How to select a gridpanel row and check Cls exist or not and add/Delete cls dynamicly



Roomy
19 Jun 2013, 2:01 AM
How to select a gridpanel row HTMLELEMENT and check Cls exist or not and add/Delete cls dynamicly

I select a row on checkboxSelectionModel pattern and looking to add/delete cls.
In 1.X extjs, Code look like that;

function UncheckCheckHeader(control)
{
var grid=<%=grdForms.ClientID%>;
var hd =Ext.get(grid.getView().getHeaderCell(0).childNodes[0]);

var store = grid.store;

if(store.getCount()== control.getCount())
{
if(!hd.hasCls('x-grid-hd-checker-on'))
{
hd.addCls('x-grid-hd-checker-on');
}
}
else
{
if(hd.hasCls('x-grid-hd-checker-on'))
{
hd.removeCls('x-grid-hd-checker-on');
}
}
}

Farish
19 Jun 2013, 6:05 AM
you can use the addRowCls, removeRowCls and getRowCls methods of the grid's view:

http://docs.sencha.com/extjs/4.2.0/#!/api/Ext.grid.View

example you want to add a class to the selected record:


var srecord = grid.getSelectionModel().getSelection(); // assuming single select; for multi-select, getSelection might return an array (if more than one records is selected)

grid.getView().addRowCls(srecord, 'myClass');

Similarly, you may use removeRowCls to remove the class or getRowCls to get the class which is applied to a record.

PS: This works with records, grid and store and not with HTML elements.