Showing posts with label extjs. Show all posts
Showing posts with label extjs. Show all posts

Monday, 8 April 2013

How to handle special key TAB or ENTER for EXTJs combobox to trigger.

Requirement is to trigger EXTJS combobox to trigger on tab change and press of enter key.
Below code is solution for above requirement.

        xtype: 'partsearchlov',
        name: 'partNumber',
        displayField: 'concatSegPartNum',
        valueField: 'concatSegPartNum',
        fieldLabel: 'Arrow Part',
        allowBlank: false,
        cls: 'required',
        minChars: 2,
        triggerAction: 'query',
        labelWidth: 80,
        listeners: {
          specialkey: function(field, e) {
            var val;
            if (e.getKey() === e.ENTER || e.getKey() === e.TAB) {
              val = field.getRawValue();
              if ( typeof val !== 'undefined') {
                if (val.indexOf('^') !== -1) {
                  val = val.slice(0, val.indexOf('^'));
                }
                field.doQuery(val, true, true);
              }
            }
          },
          scope: me

        }

Thursday, 7 March 2013

How to trigger extjs combox on click of ENTER and TAB Key


Problem: I have one combobox, want to trigger the combobox on keypress of      ENTER and TAB key

Solution:  Use specialkey listener to handle ENTER and TAB key then you doQuery() method to trigger combobox.

 Version: EXTJS 4.1
Code:


   listeners: {
        specialKey :  function(field,e) {
            if(e.getKey() === e.ENTER || e.getKey() === e.TAB){
             field.doQuery(field.getRawValue(),true,true)
            }
         }
    }

Friday, 15 June 2012

How word-wrap cell text on extjs grid

I use following way to wrap the cell text in extjs grid.

{
 header : 'Error Message',
 dataIndex : 'errorMessage',
 renderer:function(val, meta, record, rowIndex, colIndex, store){
  return '<div style="white-space:normal !important;">'+ val +'</div>';
}
}

Tuesday, 12 June 2012

How to refresh paging toolbar data on store reload

Below code will refresh paging toolbar data on store reload.
(Issue is when you are in second page and try to reload the store, you will see paging tool bar is not refreshing to starting page.)



 store.load({start:0,limit:25});  
 store.loadPage(1);

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);
}
}
}

Thursday, 10 May 2012

How to change grid column header name in extjs



Suppose I have below grid. I want to change header 2 to  "Inst" from "Instance".

    var grid = new Ext.grid.GridPanel({
        store: store,
        columns: [new Ext.grid.RowNumberer({width: 30}),
            {header: "Date", width: 50, dataIndex: 'timestamp', sortable: true},
            {header: "Instance", width: 120, dataIndex: 'olt', sortable: true},
            {header: "DL", width: 50, dataIndex: 'dl', sortable: true}
        ], ...

In extjs 3.x :

   Use the code like this
  grid.getColumnModel().setColumnHeader(2,'Inst');


In extjs 4.x :

   Use the code like this.
   grid.columns[1].setText('Inst');