Showing posts with label How deal with checkbox in extjs grid. Show all posts
Showing posts with label How deal with checkbox in extjs grid. Show all posts

Tuesday, 12 June 2012

How deal with checkbox in extjs grid

There are few ways to implement checkbox in extjs grid. However, I feel below one is the good one.

Use below code in grid.
{
  header : 'Reviewed',
  align:'center',
  renderer:function(val, meta, record, rowIndex, colIndex, store){
      return Ext.String.format('<input name="review[]" type="checkbox" value="{       0}">',record.get('id'));
}// here i am passing "id" value as part of check box. 
I  have one button to get those values and use it for further processing.



{
xtype: 'button',
text:'Apply Changes',
listeners : {
 click : function(){
var aunarray = "";
var check = document.getElementsByName('review[]');
var checkLength = check.length;
 for(var i=0; i < checkLength; i++){
  if(check[i].checked){
    aunarray = aunarray+","+check[i].value;
   }
 }
DW.App.getController('AdminNotification').appplyChanges(aunarray);
}
}
}